From 09ea67e613a80bb4265ebc41f56cf5b17976ef15 Mon Sep 17 00:00:00 2001 From: Amjad Alsharafi Date: Wed, 2 Sep 2020 11:47:57 +0800 Subject: [PATCH] Fixed the error message of invalid array element access in ch03.2 --- .../output.txt | 17 +++++++++++++---- src/ch03-02-data-types.md | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/listings/ch03-common-programming-concepts/no-listing-15-invalid-array-access/output.txt b/listings/ch03-common-programming-concepts/no-listing-15-invalid-array-access/output.txt index be3ef310f..273b34711 100644 --- a/listings/ch03-common-programming-concepts/no-listing-15-invalid-array-access/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-15-invalid-array-access/output.txt @@ -1,6 +1,15 @@ $ cargo run Compiling arrays v0.1.0 (file:///projects/arrays) - Finished dev [unoptimized + debuginfo] target(s) in 0.31s - Running `target/debug/arrays` -thread 'main' panicked at 'index out of bounds: the len is 5 but the index is 10', src/main.rs:5:19 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. +error: this operation will panic at runtime + --> src/main.rs:5:19 + | +5 | let element = a[index]; + | ^^^^^^^^ index out of bounds: the len is 5 but the index is 10 + | + = note: `#[deny(unconditional_panic)]` on by default + +error: aborting due to previous error + +error: could not compile `arrays`. + +To learn more, run the command again with --verbose. diff --git a/src/ch03-02-data-types.md b/src/ch03-02-data-types.md index f76d54bd5..62111c724 100644 --- a/src/ch03-02-data-types.md +++ b/src/ch03-02-data-types.md @@ -320,7 +320,7 @@ compile but exit with an error when it runs: Filename: src/main.rs -```rust,ignore,panics +```rust,ignore,does_not_compile {{#rustdoc_include ../listings/ch03-common-programming-concepts/no-listing-15-invalid-array-access/src/main.rs}} ```