Skip to content

Commit

Permalink
make both panic display formats collapse frames
Browse files Browse the repository at this point in the history
  • Loading branch information
KodrAus authored and JDuchniewicz committed Jun 7, 2021
1 parent 5fb2986 commit 8423a19
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions library/std/src/backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,11 @@ impl fmt::Display for Backtrace {
let mut f = backtrace_rs::BacktraceFmt::new(fmt, style, &mut print_path);
f.add_context()?;
for frame in frames {
let mut f = f.frame();
if frame.symbols.is_empty() {
f.print_raw(frame.frame.ip(), None, None, None)?;
f.frame().print_raw(frame.frame.ip(), None, None, None)?;
} else {
for symbol in frame.symbols.iter() {
f.print_raw_with_column(
f.frame().print_raw_with_column(
frame.frame.ip(),
symbol.name.as_ref().map(|b| backtrace_rs::SymbolName::new(b)),
symbol.filename.as_ref().map(|b| match b {
Expand Down
5 changes: 2 additions & 3 deletions library/std/src/sys_common/backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt::

let mut hit = false;
let mut stop = false;
let mut frame_fmt = bt_fmt.frame();
backtrace_rs::resolve_frame_unsynchronized(frame, |symbol| {
hit = true;
if print_fmt == PrintFmt::Short {
Expand All @@ -88,15 +87,15 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt::
}

if start {
res = frame_fmt.symbol(frame, symbol);
res = bt_fmt.frame().symbol(frame, symbol);
}
});
if stop {
return false;
}
if !hit {
if start {
res = frame_fmt.print_raw(frame.ip(), None, None, None);
res = bt_fmt.frame().print_raw(frame.ip(), None, None, None);
}
}

Expand Down

0 comments on commit 8423a19

Please sign in to comment.