File tree 2 files changed +6
-3
lines changed
compiler/rustc_const_eval/src/interpret
2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ impl<Prov: Provenance> Immediate<Prov> {
118
118
( Immediate :: Scalar ( scalar) , Abi :: Scalar ( s) ) => {
119
119
assert_eq ! ( scalar. size( ) , s. size( cx) ) ;
120
120
if !matches ! ( s. primitive( ) , abi:: Pointer ( ..) ) {
121
+ // This is not a pointer, it should not carry provenance.
121
122
assert ! ( matches!( scalar, Scalar :: Int ( ..) ) ) ;
122
123
}
123
124
}
Original file line number Diff line number Diff line change @@ -652,6 +652,8 @@ where
652
652
M :: after_local_write ( self , local, /*storage_live*/ false ) ?;
653
653
}
654
654
// Double-check that the value we are storing and the local fit to each other.
655
+ // Things can ge wrong in quite weird ways when this is violated.
656
+ // Unfortunately this is too expensive to do in release builds.
655
657
if cfg ! ( debug_assertions) {
656
658
src. assert_matches_abi ( local_layout. abi , self ) ;
657
659
}
@@ -672,9 +674,9 @@ where
672
674
layout : TyAndLayout < ' tcx > ,
673
675
dest : MemPlace < M :: Provenance > ,
674
676
) -> InterpResult < ' tcx > {
675
- if cfg ! ( debug_assertions ) {
676
- value . assert_matches_abi ( layout . abi , self ) ;
677
- }
677
+ // We use the sizes from `value` below.
678
+ // Ensure that matches the type of the place it is written to.
679
+ value . assert_matches_abi ( layout . abi , self ) ;
678
680
// Note that it is really important that the type here is the right one, and matches the
679
681
// type things are read at. In case `value` is a `ScalarPair`, we don't do any magic here
680
682
// to handle padding properly, which is only correct if we never look at this data with the
You can’t perform that action at this time.
0 commit comments