From f389d46b04c42c3f85ceeb182eabeac94a392b7b Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 29 Jun 2022 09:33:12 -0400 Subject: [PATCH] also prune caller_location frames when backtrace=off --- src/diagnostics.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/diagnostics.rs b/src/diagnostics.rs index 95252a113429..55598c19ef6b 100644 --- a/src/diagnostics.rs +++ b/src/diagnostics.rs @@ -96,6 +96,9 @@ fn prune_stacktrace<'mir, 'tcx>( ) -> (Vec>, bool) { match ecx.machine.backtrace_style { BacktraceStyle::Off => { + // Remove all frames marked with `caller_location` -- that attribute indicates we + // usually want to point at the caller, not them. + stacktrace.retain(|frame| !frame.instance.def.requires_caller_location(*ecx.tcx)); // Retain one frame so that we can print a span for the error itself stacktrace.truncate(1); (stacktrace, false)