@@ -15,8 +15,8 @@ use rustc_target::abi::{Abi, DiscriminantKind, HasDataLayout, LayoutOf, Size};
1515use rustc_target:: abi:: { VariantIdx , Variants } ;
1616
1717use 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 ,
2020} ;
2121
2222/// 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> {
469469 . try_fold ( base_op, |op, elem| self . operand_projection ( op, elem) ) ?;
470470
471471 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+ ) ) ;
472480 Ok ( op)
473481 }
474482
0 commit comments