@@ -17,7 +17,7 @@ use rustc_middle::ty::layout::{self, TyAndLayout};
17
17
use rustc_middle:: ty:: {
18
18
self , fold:: BottomUpFolder , query:: TyCtxtAt , subst:: SubstsRef , Ty , TyCtxt , TypeFoldable ,
19
19
} ;
20
- use rustc_span:: source_map:: DUMMY_SP ;
20
+ use rustc_span:: { source_map:: DUMMY_SP , Span } ;
21
21
use rustc_target:: abi:: { Align , HasDataLayout , LayoutOf , Size , TargetDataLayout } ;
22
22
23
23
use super :: {
@@ -256,7 +256,7 @@ pub(super) fn mir_assign_valid_types<'tcx>(
256
256
/// or compute the layout.
257
257
#[ cfg_attr( not( debug_assertions) , inline( always) ) ]
258
258
pub ( super ) fn from_known_layout < ' tcx > (
259
- tcx : TyCtxt < ' tcx > ,
259
+ tcx : TyCtxtAt < ' tcx > ,
260
260
known_layout : Option < TyAndLayout < ' tcx > > ,
261
261
compute : impl FnOnce ( ) -> InterpResult < ' tcx , TyAndLayout < ' tcx > > ,
262
262
) -> InterpResult < ' tcx , TyAndLayout < ' tcx > > {
@@ -265,12 +265,14 @@ pub(super) fn from_known_layout<'tcx>(
265
265
Some ( known_layout) => {
266
266
if cfg ! ( debug_assertions) {
267
267
let check_layout = compute ( ) ?;
268
- assert ! (
269
- mir_assign_valid_types( tcx, check_layout, known_layout) ,
270
- "expected type differs from actual type.\n expected: {:?}\n actual: {:?}" ,
271
- known_layout. ty,
272
- check_layout. ty,
273
- ) ;
268
+ if !mir_assign_valid_types ( tcx. tcx , check_layout, known_layout) {
269
+ span_bug ! (
270
+ tcx. span,
271
+ "expected type differs from actual type.\n expected: {:?}\n actual: {:?}" ,
272
+ known_layout. ty,
273
+ check_layout. ty,
274
+ ) ;
275
+ }
274
276
}
275
277
Ok ( known_layout)
276
278
}
@@ -294,6 +296,12 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
294
296
}
295
297
}
296
298
299
+ #[ inline( always) ]
300
+ pub fn set_span ( & mut self , span : Span ) {
301
+ self . tcx . span = span;
302
+ self . memory . tcx . span = span;
303
+ }
304
+
297
305
#[ inline( always) ]
298
306
pub fn force_ptr (
299
307
& self ,
@@ -444,7 +452,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
444
452
// have to support that case (mostly by skipping all caching).
445
453
match frame. locals . get ( local) . and_then ( |state| state. layout . get ( ) ) {
446
454
None => {
447
- let layout = from_known_layout ( self . tcx . tcx , layout, || {
455
+ let layout = from_known_layout ( self . tcx , layout, || {
448
456
let local_ty = frame. body . local_decls [ local] . ty ;
449
457
let local_ty =
450
458
self . subst_from_frame_and_normalize_erasing_regions ( frame, local_ty) ;
0 commit comments