@@ -17,7 +17,7 @@ use rustc_middle::ty::layout::{self, TyAndLayout};
1717use rustc_middle:: ty:: {
1818 self , fold:: BottomUpFolder , query:: TyCtxtAt , subst:: SubstsRef , Ty , TyCtxt , TypeFoldable ,
1919} ;
20- use rustc_span:: source_map:: DUMMY_SP ;
20+ use rustc_span:: { source_map:: DUMMY_SP , Span } ;
2121use rustc_target:: abi:: { Align , HasDataLayout , LayoutOf , Size , TargetDataLayout } ;
2222
2323use super :: {
@@ -256,7 +256,7 @@ pub(super) fn mir_assign_valid_types<'tcx>(
256256/// or compute the layout.
257257#[ cfg_attr( not( debug_assertions) , inline( always) ) ]
258258pub ( super ) fn from_known_layout < ' tcx > (
259- tcx : TyCtxt < ' tcx > ,
259+ tcx : TyCtxtAt < ' tcx > ,
260260 known_layout : Option < TyAndLayout < ' tcx > > ,
261261 compute : impl FnOnce ( ) -> InterpResult < ' tcx , TyAndLayout < ' tcx > > ,
262262) -> InterpResult < ' tcx , TyAndLayout < ' tcx > > {
@@ -265,12 +265,14 @@ pub(super) fn from_known_layout<'tcx>(
265265 Some ( known_layout) => {
266266 if cfg ! ( debug_assertions) {
267267 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+ }
274276 }
275277 Ok ( known_layout)
276278 }
@@ -294,6 +296,12 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
294296 }
295297 }
296298
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+
297305 #[ inline( always) ]
298306 pub fn force_ptr (
299307 & self ,
@@ -444,7 +452,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
444452 // have to support that case (mostly by skipping all caching).
445453 match frame. locals . get ( local) . and_then ( |state| state. layout . get ( ) ) {
446454 None => {
447- let layout = from_known_layout ( self . tcx . tcx , layout, || {
455+ let layout = from_known_layout ( self . tcx , layout, || {
448456 let local_ty = frame. body . local_decls [ local] . ty ;
449457 let local_ty =
450458 self . subst_from_frame_and_normalize_erasing_regions ( frame, local_ty) ;
0 commit comments