Skip to content

Commit 09ea67e

Browse files
committed
Fixed the error message of invalid array element access in ch03.2
1 parent e5ed971 commit 09ea67e

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
$ cargo run
22
Compiling arrays v0.1.0 (file:///projects/arrays)
3-
Finished dev [unoptimized + debuginfo] target(s) in 0.31s
4-
Running `target/debug/arrays`
5-
thread 'main' panicked at 'index out of bounds: the len is 5 but the index is 10', src/main.rs:5:19
6-
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
3+
error: this operation will panic at runtime
4+
--> src/main.rs:5:19
5+
|
6+
5 | let element = a[index];
7+
| ^^^^^^^^ index out of bounds: the len is 5 but the index is 10
8+
|
9+
= note: `#[deny(unconditional_panic)]` on by default
10+
11+
error: aborting due to previous error
12+
13+
error: could not compile `arrays`.
14+
15+
To learn more, run the command again with --verbose.

src/ch03-02-data-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ compile but exit with an error when it runs:
320320

321321
<span class="filename">Filename: src/main.rs</span>
322322

323-
```rust,ignore,panics
323+
```rust,ignore,does_not_compile
324324
{{#rustdoc_include ../listings/ch03-common-programming-concepts/no-listing-15-invalid-array-access/src/main.rs}}
325325
```
326326

0 commit comments

Comments
 (0)