-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Formatting of std::backtrace::Backtrace #65280
Copy link
Copy link
Open
Labels
A-backtraceArea: BacktracesArea: BacktracesC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.PG-error-handlingProject group: Error handling (https://github.com/rust-lang/project-error-handling)Project group: Error handling (https://github.com/rust-lang/project-error-handling)T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-backtraceArea: BacktracesArea: BacktracesC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.PG-error-handlingProject group: Error handling (https://github.com/rust-lang/project-error-handling)Project group: Error handling (https://github.com/rust-lang/project-error-handling)T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
I'd like to propose some changes to formatting of the
Backtracetype introduced in #53487.Don't include newlines in the default
Debugoutput. I personally find it pretty jarring when looking at the debug output of an error where everything is on the same line except the backtrace, and then any additional properties are printed way down on the last line.I'd suggest instead printing a "list" of "maps", such that it'd look like
[{ function: "errors::new", file: "./src/new.rs", line: 21 }, ...].Allow passing the "precision" format flag to limit how many frames are printed. The most relevant frames are normally near the top, but deciding exactly how many depends on the app. Then a user could write
println!("short trace: {:.5}", trace)to see just 5 frames.Remove
stack backtrace:\nprefix entirely. When formatting, I'd think a user would pick their own prefix, likeprintln!("Call stack:\n{}", trace).