]> git.lizzy.rs Git - rust.git/commitdiff
also prune caller_location frames when backtrace=off
authorRalf Jung <post@ralfj.de>
Wed, 29 Jun 2022 13:33:12 +0000 (09:33 -0400)
committerRalf Jung <post@ralfj.de>
Wed, 29 Jun 2022 13:33:12 +0000 (09:33 -0400)
src/diagnostics.rs

index 95252a11342942caefada0c31553f147eb6b3a0e..55598c19ef6b772584d509b69aa7f790ef2a0a60 100644 (file)
@@ -96,6 +96,9 @@ fn prune_stacktrace<'mir, 'tcx>(
 ) -> (Vec<FrameInfo<'tcx>>, bool) {
     match ecx.machine.backtrace_style {
         BacktraceStyle::Off => {
 ) -> (Vec<FrameInfo<'tcx>>, 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)
             // Retain one frame so that we can print a span for the error itself
             stacktrace.truncate(1);
             (stacktrace, false)