mirror of
https://github.com/rust-lang-cn/book-cn.git
synced 2025-01-26 09:18:42 +08:00
remove second backtrace
This commit is contained in:
parent
e35e0e1039
commit
80c97251b8
@ -96,46 +96,7 @@ error: Process didn't exit successfully: `target/debug/panic` (exit code: 101)
|
||||
```
|
||||
|
||||
That's a lot of output! Line `11` there has the line in our project:
|
||||
`src/main.rs` line four. We've been looking at the error message, but Cargo
|
||||
also told us something important about backtraces early on: `[unoptimized +
|
||||
debuginfo]`. 'debuginfo' is what enables the file names to be shown here.
|
||||
If we instead compile with `--release`:
|
||||
|
||||
```bash
|
||||
$ RUST_BACKTRACE=1 cargo run --release
|
||||
Compiling panic v0.1.0 (file:///home/steve/tmp/panic)
|
||||
Finished release [optimized] target(s) in 0.28 secs
|
||||
Running `target/release/panic`
|
||||
thread 'main' panicked at 'index out of bounds: the len is 3 but the index is
|
||||
100', ../src/libcollections/vec.rs:1265
|
||||
stack backtrace:
|
||||
1: 0x565238fd0e79 -
|
||||
std::sys::backtrace::tracing::imp::write::h482d45d91246faa2
|
||||
2: 0x565238fd37ec -
|
||||
std::panicking::default_hook::_{{closure}}::h89158f66286b674e
|
||||
3: 0x565238fd2cae - std::panicking::default_hook::h9e30d428ee3b0c43
|
||||
4: 0x565238fd3318 -
|
||||
std::panicking::rust_panic_with_hook::h2224f33fb7bf2f4c
|
||||
5: 0x565238fd31b2 - std::panicking::begin_panic::hcb11a4dc6d779ae5
|
||||
6: 0x565238fd30e0 - std::panicking::begin_panic_fmt::h310416c62f3935b3
|
||||
7: 0x565238fd3061 - rust_begin_unwind
|
||||
8: 0x565239008dbf - core::panicking::panic_fmt::hc5789f4e80194729
|
||||
9: 0x565239008d63 -
|
||||
core::panicking::panic_bounds_check::hb2d969c3cc11ed08
|
||||
10: 0x565238fcc526 - panic::main::h2d7d3751fb8705e2
|
||||
11: 0x565238fdb2d6 - __rust_maybe_catch_panic
|
||||
12: 0x565238fd2412 - std::rt::lang_start::h352a66f5026f54bd
|
||||
13: 0x7f36aad6372f - __libc_start_main
|
||||
14: 0x565238fcc408 - _start
|
||||
15: 0x0 - <unknown>
|
||||
error: Process didn't exit successfully: `target/release/panic` (exit code:
|
||||
101)
|
||||
```
|
||||
|
||||
Now it just says 'optimized', and we don't have the file names any more. These
|
||||
settings are only the default; you can include debuginfo in a release build,
|
||||
or exclude it from a debug build, by configuring Cargo. See its documentation
|
||||
for more details: http://doc.crates.io/manifest.html#the-profile-sections
|
||||
`src/main.rs` line four.
|
||||
|
||||
So why does Rust panic here? In this case, using `[]` is supposed to return
|
||||
a number. But if you pass it an invalid index, there's no number Rust could
|
||||
|
Loading…
Reference in New Issue
Block a user