@@ -15,8 +15,8 @@ use rustc_target::abi::{Abi, DiscriminantKind, HasDataLayout, LayoutOf, Size};
15
15
use rustc_target:: abi:: { VariantIdx , Variants } ;
16
16
17
17
use super :: {
18
- from_known_layout, ConstValue , GlobalId , InterpCx , InterpResult , MPlaceTy , Machine , MemPlace ,
19
- Place , PlaceTy , Pointer , Scalar , ScalarMaybeUninit ,
18
+ from_known_layout, mir_assign_valid_types , ConstValue , GlobalId , InterpCx , InterpResult ,
19
+ MPlaceTy , Machine , MemPlace , Place , PlaceTy , Pointer , Scalar , ScalarMaybeUninit ,
20
20
} ;
21
21
22
22
/// An `Immediate` represents a single immediate self-contained Rust value.
@@ -469,6 +469,14 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
469
469
. try_fold ( base_op, |op, elem| self . operand_projection ( op, elem) ) ?;
470
470
471
471
trace ! ( "eval_place_to_op: got {:?}" , * op) ;
472
+ // Sanity-check the type we ended up with.
473
+ debug_assert ! ( mir_assign_valid_types(
474
+ * self . tcx,
475
+ self . layout_of( self . subst_from_current_frame_and_normalize_erasing_regions(
476
+ place. ty( & self . frame( ) . body. local_decls, * self . tcx) . ty
477
+ ) ) ?,
478
+ op. layout,
479
+ ) ) ;
472
480
Ok ( op)
473
481
}
474
482
0 commit comments