@@ -4,7 +4,7 @@ use std::num::NonZeroU64;
44
55use log:: trace;
66
7- use rustc_middle:: ty:: { self , TyCtxt } ;
7+ use rustc_middle:: ty;
88use rustc_span:: { source_map:: DUMMY_SP , Span , SpanData , Symbol } ;
99
1010use crate :: stacked_borrows:: { AccessKind , SbTag } ;
@@ -94,7 +94,7 @@ fn prune_stacktrace<'mir, 'tcx>(
9494 // Only prune frames if there is at least one local frame. This check ensures that if
9595 // we get a backtrace that never makes it to the user code because it has detected a
9696 // bug in the Rust runtime, we don't prune away every frame.
97- let has_local_frame = stacktrace. iter ( ) . any ( |frame| frame . instance . def_id ( ) . is_local ( ) ) ;
97+ let has_local_frame = stacktrace. iter ( ) . any ( |frame| ecx . machine . is_local ( frame ) ) ;
9898 if has_local_frame {
9999 // This is part of the logic that `std` uses to select the relevant part of a
100100 // backtrace. But here, we only look for __rust_begin_short_backtrace, not
@@ -115,7 +115,7 @@ fn prune_stacktrace<'mir, 'tcx>(
115115 // This len check ensures that we don't somehow remove every frame, as doing so breaks
116116 // the primary error message.
117117 while stacktrace. len ( ) > 1
118- && stacktrace. last ( ) . map_or ( false , |e | !e . instance . def_id ( ) . is_local ( ) )
118+ && stacktrace. last ( ) . map_or ( false , |frame | !ecx . machine . is_local ( frame ) )
119119 {
120120 stacktrace. pop ( ) ;
121121 }
@@ -218,7 +218,7 @@ pub fn report_error<'tcx, 'mir>(
218218 e. print_backtrace ( ) ;
219219 msg. insert ( 0 , e. to_string ( ) ) ;
220220 report_msg (
221- * ecx. tcx ,
221+ ecx,
222222 DiagLevel :: Error ,
223223 & if let Some ( title) = title { format ! ( "{}: {}" , title, msg[ 0 ] ) } else { msg[ 0 ] . clone ( ) } ,
224224 msg,
@@ -264,19 +264,20 @@ pub fn report_error<'tcx, 'mir>(
264264/// We want to present a multi-line span message for some errors. Diagnostics do not support this
265265/// directly, so we pass the lines as a `Vec<String>` and display each line after the first with an
266266/// additional `span_label` or `note` call.
267- fn report_msg < ' tcx > (
268- tcx : TyCtxt < ' tcx > ,
267+ fn report_msg < ' mir , ' tcx > (
268+ ecx : & InterpCx < ' mir , ' tcx , Evaluator < ' mir , ' tcx > > ,
269269 diag_level : DiagLevel ,
270270 title : & str ,
271271 span_msg : Vec < String > ,
272272 mut helps : Vec < ( Option < SpanData > , String ) > ,
273273 stacktrace : & [ FrameInfo < ' tcx > ] ,
274274) {
275275 let span = stacktrace. first ( ) . map_or ( DUMMY_SP , |fi| fi. span ) ;
276+ let sess = ecx. tcx . sess ;
276277 let mut err = match diag_level {
277- DiagLevel :: Error => tcx . sess . struct_span_err ( span, title) . forget_guarantee ( ) ,
278- DiagLevel :: Warning => tcx . sess . struct_span_warn ( span, title) ,
279- DiagLevel :: Note => tcx . sess . diagnostic ( ) . span_note_diag ( span, title) ,
278+ DiagLevel :: Error => sess. struct_span_err ( span, title) . forget_guarantee ( ) ,
279+ DiagLevel :: Warning => sess. struct_span_warn ( span, title) ,
280+ DiagLevel :: Note => sess. diagnostic ( ) . span_note_diag ( span, title) ,
280281 } ;
281282
282283 // Show main message.
@@ -306,7 +307,7 @@ fn report_msg<'tcx>(
306307 }
307308 // Add backtrace
308309 for ( idx, frame_info) in stacktrace. iter ( ) . enumerate ( ) {
309- let is_local = frame_info . instance . def_id ( ) . is_local ( ) ;
310+ let is_local = ecx . machine . is_local ( frame_info ) ;
310311 // No span for non-local frames and the first frame (which is the error site).
311312 if is_local && idx > 0 {
312313 err. span_note ( frame_info. span , & frame_info. to_string ( ) ) ;
@@ -426,7 +427,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
426427 _ => ( "tracking was triggered" , DiagLevel :: Note ) ,
427428 } ;
428429
429- report_msg ( * this. tcx , diag_level, title, vec ! [ msg] , vec ! [ ] , & stacktrace) ;
430+ report_msg ( this, diag_level, title, vec ! [ msg] , vec ! [ ] , & stacktrace) ;
430431 }
431432 } ) ;
432433 }
0 commit comments