Skip to content

Commit 5130aa5

Browse files
committed
adjust stacktrace printing to rustc changes
1 parent 77a307f commit 5130aa5

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/diagnostics.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,11 @@ fn report_msg<'tcx, 'mir>(
130130
}
131131
// Add backtrace
132132
let frames = ecx.generate_stacktrace(None);
133-
// We iterate with indices because we need to look at the next frame (the caller).
134-
for idx in 0..frames.len() {
135-
let frame_info = &frames[idx];
136-
let call_site_is_local = frames
137-
.get(idx + 1)
138-
.map_or(false, |caller_info| caller_info.instance.def_id().is_local());
139-
if call_site_is_local {
140-
err.span_note(frame_info.call_site, &frame_info.to_string());
133+
for (idx, frame_info) in frames.iter().enumerate() {
134+
let is_local = frame_info.instance.def_id().is_local();
135+
// No span for non-local frames and the first frame (which is the error site).
136+
if is_local && idx > 0 {
137+
err.span_note(frame_info.span, &frame_info.to_string());
141138
} else {
142139
err.note(&frame_info.to_string());
143140
}

tests/compile-fail/never_transmute_void.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
enum Void {}
88

99
fn f(v: Void) -> ! {
10-
match v {} //~ ERROR entering unreachable code
10+
match v {} //~ ERROR entering unreachable code
1111
}
1212

1313
fn main() {
1414
let v: Void = unsafe {
1515
std::mem::transmute::<(), Void>(())
1616
};
17-
f(v); //~ inside call to `f`
17+
f(v); //~ inside `main`
1818
}

0 commit comments

Comments
 (0)