@@ -4,7 +4,7 @@ use std::num::NonZeroU64;
4
4
5
5
use log:: trace;
6
6
7
- use rustc_middle:: ty:: { self , TyCtxt } ;
7
+ use rustc_middle:: ty;
8
8
use rustc_span:: { source_map:: DUMMY_SP , Span , SpanData , Symbol } ;
9
9
10
10
use crate :: stacked_borrows:: { AccessKind , SbTag } ;
@@ -94,7 +94,7 @@ fn prune_stacktrace<'mir, 'tcx>(
94
94
// Only prune frames if there is at least one local frame. This check ensures that if
95
95
// we get a backtrace that never makes it to the user code because it has detected a
96
96
// 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 ) ) ;
98
98
if has_local_frame {
99
99
// This is part of the logic that `std` uses to select the relevant part of a
100
100
// backtrace. But here, we only look for __rust_begin_short_backtrace, not
@@ -115,7 +115,7 @@ fn prune_stacktrace<'mir, 'tcx>(
115
115
// This len check ensures that we don't somehow remove every frame, as doing so breaks
116
116
// the primary error message.
117
117
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 ) )
119
119
{
120
120
stacktrace. pop ( ) ;
121
121
}
@@ -218,7 +218,7 @@ pub fn report_error<'tcx, 'mir>(
218
218
e. print_backtrace ( ) ;
219
219
msg. insert ( 0 , e. to_string ( ) ) ;
220
220
report_msg (
221
- * ecx. tcx ,
221
+ ecx,
222
222
DiagLevel :: Error ,
223
223
& if let Some ( title) = title { format ! ( "{}: {}" , title, msg[ 0 ] ) } else { msg[ 0 ] . clone ( ) } ,
224
224
msg,
@@ -264,19 +264,20 @@ pub fn report_error<'tcx, 'mir>(
264
264
/// We want to present a multi-line span message for some errors. Diagnostics do not support this
265
265
/// directly, so we pass the lines as a `Vec<String>` and display each line after the first with an
266
266
/// 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 > > ,
269
269
diag_level : DiagLevel ,
270
270
title : & str ,
271
271
span_msg : Vec < String > ,
272
272
mut helps : Vec < ( Option < SpanData > , String ) > ,
273
273
stacktrace : & [ FrameInfo < ' tcx > ] ,
274
274
) {
275
275
let span = stacktrace. first ( ) . map_or ( DUMMY_SP , |fi| fi. span ) ;
276
+ let sess = ecx. tcx . sess ;
276
277
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) ,
280
281
} ;
281
282
282
283
// Show main message.
@@ -306,7 +307,7 @@ fn report_msg<'tcx>(
306
307
}
307
308
// Add backtrace
308
309
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 ) ;
310
311
// No span for non-local frames and the first frame (which is the error site).
311
312
if is_local && idx > 0 {
312
313
err. span_note ( frame_info. span , & frame_info. to_string ( ) ) ;
@@ -426,7 +427,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
426
427
_ => ( "tracking was triggered" , DiagLevel :: Note ) ,
427
428
} ;
428
429
429
- report_msg ( * this. tcx , diag_level, title, vec ! [ msg] , vec ! [ ] , & stacktrace) ;
430
+ report_msg ( this, diag_level, title, vec ! [ msg] , vec ! [ ] , & stacktrace) ;
430
431
}
431
432
} ) ;
432
433
}
0 commit comments