From 5130aa55a2d5e846b491a58a19aad8e00554d61f Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 30 Mar 2020 20:15:02 +0200 Subject: [PATCH] adjust stacktrace printing to rustc changes --- src/diagnostics.rs | 13 +++++-------- tests/compile-fail/never_transmute_void.rs | 4 ++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/diagnostics.rs b/src/diagnostics.rs index a528960cb26..8595551b6cb 100644 --- a/src/diagnostics.rs +++ b/src/diagnostics.rs @@ -130,14 +130,11 @@ fn report_msg<'tcx, 'mir>( } // Add backtrace let frames = ecx.generate_stacktrace(None); - // We iterate with indices because we need to look at the next frame (the caller). - for idx in 0..frames.len() { - let frame_info = &frames[idx]; - let call_site_is_local = frames - .get(idx + 1) - .map_or(false, |caller_info| caller_info.instance.def_id().is_local()); - if call_site_is_local { - err.span_note(frame_info.call_site, &frame_info.to_string()); + for (idx, frame_info) in frames.iter().enumerate() { + let is_local = frame_info.instance.def_id().is_local(); + // No span for non-local frames and the first frame (which is the error site). + if is_local && idx > 0 { + err.span_note(frame_info.span, &frame_info.to_string()); } else { err.note(&frame_info.to_string()); } diff --git a/tests/compile-fail/never_transmute_void.rs b/tests/compile-fail/never_transmute_void.rs index 2a822ab1b51..5e9e2ac204e 100644 --- a/tests/compile-fail/never_transmute_void.rs +++ b/tests/compile-fail/never_transmute_void.rs @@ -7,12 +7,12 @@ enum Void {} fn f(v: Void) -> ! { - match v {} //~ ERROR entering unreachable code + match v {} //~ ERROR entering unreachable code } fn main() { let v: Void = unsafe { std::mem::transmute::<(), Void>(()) }; - f(v); //~ inside call to `f` + f(v); //~ inside `main` } -- 2.44.0