Skip to content

Commit 2250f51

Browse files
committed
Panic now points at our code, not stdlib slice code
Fixes #2550.
1 parent 24e275d commit 2250f51

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

src/ch09-01-unrecoverable-errors-with-panic.md

+12-16
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,18 @@ continue. Let’s try it and see:
9090
{{#include ../listings/ch09-error-handling/listing-09-01/output.txt}}
9191
```
9292

93-
This error points at a file we didn’t write, *libcore/slice/mod.rs*. That’s the
94-
implementation of `slice` in the Rust source code. The code that gets run when
95-
we use `[]` on our vector `v` is in *libcore/slice/mod.rs*, and that is where
96-
the `panic!` is actually happening.
97-
98-
The next note line tells us that we can set the `RUST_BACKTRACE` environment
99-
variable to get a backtrace of exactly what happened to cause the error. A
100-
*backtrace* is a list of all the functions that have been called to get to this
101-
point. Backtraces in Rust work as they do in other languages: the key to
102-
reading the backtrace is to start from the top and read until you see files you
103-
wrote. That’s the spot where the problem originated. The lines above the lines
104-
mentioning your files are code that your code called; the lines below are code
105-
that called your code. These lines might include core Rust code, standard
106-
library code, or crates that you’re using. Let’s try getting a backtrace by
107-
setting the `RUST_BACKTRACE` environment variable to any value except 0.
108-
Listing 9-2 shows output similar to what you’ll see.
93+
This error points at line 4 of our `main.rs` where we attempt to access index
94+
99. The next note line tells us that we can set the `RUST_BACKTRACE`
95+
environment variable to get a backtrace of exactly what happened to cause the
96+
error. A *backtrace* is a list of all the functions that have been called to
97+
get to this point. Backtraces in Rust work as they do in other languages: the
98+
key to reading the backtrace is to start from the top and read until you see
99+
files you wrote. That’s the spot where the problem originated. The lines above
100+
the lines mentioning your files are code that your code called; the lines below
101+
are code that called your code. These lines might include core Rust code,
102+
standard library code, or crates that you’re using. Let’s try getting a
103+
backtrace by setting the `RUST_BACKTRACE` environment variable to any value
104+
except 0. Listing 9-2 shows output similar to what you’ll see.
109105

110106
<!-- manual-regeneration
111107
cd listings/ch09-error-handling/listing-09-01

0 commit comments

Comments
 (0)