hide panic internals in short backtraces
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
right now, nearly all foo.expect("bar") backtraces start like this:
stack backtrace:
0: rust_begin_unwind
at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/std/src/panicking.rs:652:5
1: core::panicking::panic_fmt
at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/core/src/panicking.rs:72:14
2: core::panicking::panic_display
at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/core/src/panicking.rs:256:5
3: core::panicking::panic_str
at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/core/src/panicking.rs:231:5
4: core::option::expect_failed
at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/core/src/option.rs:1994:5
5: core::option::Option<T>::expect
at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/core/src/option.rs:895:21
this is not super useful. it doesn't add any information, other than maybe the very last frame which says you called expect(). it would be nice to omit anything in the core::panicking module from the backtrace; and maybe expect_failed and the core::ops::function::FnOnce::call_once that show up at the end of the backtrace as well. people can always opt back in with RUST_BACKTRACE=full.
the code for this lives in https://github.com/rust-lang/rust/blob/378a43a06510f3e3a49c69c8de71745e6a884048/library/std/src/sys_common/backtrace.rs#L77-L81
@rustbot label +T-libs +A-runtime
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at library/std/src/sys_common/backtrace.rs lines 77-81 and compare the current short backtrace with RUST_BACKTRACE=full. Define which core::panicking and trailing internal frames are omitted in short mode, while full mode continues to show them; done means expect() backtraces emphasize application frames.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 43/100