Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit f389d46

Browse files
committed
also prune caller_location frames when backtrace=off
1 parent ea8dba4 commit f389d46

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/diagnostics.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ fn prune_stacktrace<'mir, 'tcx>(
9696
) -> (Vec<FrameInfo<'tcx>>, bool) {
9797
match ecx.machine.backtrace_style {
9898
BacktraceStyle::Off => {
99+
// Remove all frames marked with `caller_location` -- that attribute indicates we
100+
// usually want to point at the caller, not them.
101+
stacktrace.retain(|frame| !frame.instance.def.requires_caller_location(*ecx.tcx));
99102
// Retain one frame so that we can print a span for the error itself
100103
stacktrace.truncate(1);
101104
(stacktrace, false)

0 commit comments

Comments
 (0)