File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
listings/ch03-common-programming-concepts/no-listing-15-invalid-array-access Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 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.
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments