File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed
compiler/rustc_const_eval/src/interpret Expand file tree Collapse file tree 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> {
118118 ( Immediate :: Scalar ( scalar) , Abi :: Scalar ( s) ) => {
119119 assert_eq ! ( scalar. size( ) , s. size( cx) ) ;
120120 if !matches ! ( s. primitive( ) , abi:: Pointer ( ..) ) {
121+ // This is not a pointer, it should not carry provenance.
121122 assert ! ( matches!( scalar, Scalar :: Int ( ..) ) ) ;
122123 }
123124 }
Original file line number Diff line number Diff line change @@ -652,6 +652,8 @@ where
652652 M :: after_local_write ( self , local, /*storage_live*/ false ) ?;
653653 }
654654 // 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.
655657 if cfg ! ( debug_assertions) {
656658 src. assert_matches_abi ( local_layout. abi , self ) ;
657659 }
@@ -672,9 +674,9 @@ where
672674 layout : TyAndLayout < ' tcx > ,
673675 dest : MemPlace < M :: Provenance > ,
674676 ) -> 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 ) ;
678680 // Note that it is really important that the type here is the right one, and matches the
679681 // type things are read at. In case `value` is a `ScalarPair`, we don't do any magic here
680682 // 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