@@ -6,8 +6,8 @@ use std::assert_matches::assert_matches;
66
77use either:: { Either , Left , Right } ;
88use rustc_abi:: { BackendRepr , HasDataLayout , Size } ;
9- use rustc_middle:: ty:: Ty ;
109use rustc_middle:: ty:: layout:: TyAndLayout ;
10+ use rustc_middle:: ty:: { self , Ty } ;
1111use rustc_middle:: { bug, mir, span_bug} ;
1212use tracing:: field:: Empty ;
1313use tracing:: { instrument, trace} ;
@@ -889,6 +889,13 @@ where
889889 // padding in the target independent of layout choices.
890890 let src_has_padding = match src. layout ( ) . backend_repr {
891891 BackendRepr :: Scalar ( _) => false ,
892+ BackendRepr :: ScalarPair ( left, right)
893+ if matches ! ( src. layout( ) . ty. kind( ) , ty:: Ref ( ..) | ty:: RawPtr ( ..) ) =>
894+ {
895+ // Wide pointers never have padding, so we can avoid calling `size()`.
896+ debug_assert_eq ! ( left. size( self ) + right. size( self ) , src. layout( ) . size) ;
897+ false
898+ }
892899 BackendRepr :: ScalarPair ( left, right) => {
893900 let left_size = left. size ( self ) ;
894901 let right_size = right. size ( self ) ;
0 commit comments