From 8423a19f66a8b98e34576186f03ce66161cd691b Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Wed, 16 Dec 2020 15:07:39 +1000 Subject: [PATCH] make both panic display formats collapse frames --- library/std/src/backtrace.rs | 5 ++--- library/std/src/sys_common/backtrace.rs | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/library/std/src/backtrace.rs b/library/std/src/backtrace.rs index 0aae4674b2942..f8884523cf446 100644 --- a/library/std/src/backtrace.rs +++ b/library/std/src/backtrace.rs @@ -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 { diff --git a/library/std/src/sys_common/backtrace.rs b/library/std/src/sys_common/backtrace.rs index 5f6318ba5d231..a549770d8b378 100644 --- a/library/std/src/sys_common/backtrace.rs +++ b/library/std/src/sys_common/backtrace.rs @@ -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 { @@ -88,7 +87,7 @@ 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 { @@ -96,7 +95,7 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt:: } 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); } }