@@ -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} ;
@@ -885,18 +885,25 @@ where
885885 dest. layout( ) . ty,
886886 ) ;
887887 }
888- // If the source has padding, we want to always do the mem-to-mem copy to ensure consistent
888+ // If the source has padding, we want to always do a mem-to-mem copy to ensure consistent
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 ) ;
895902 // We have padding if the sizes don't add up to the total.
896903 left_size + right_size != src. layout ( ) . size
897904 }
898- // Everything else can only exist in memory anyway.
899- _ => true ,
905+ // Everything else can only exist in memory anyway, so it doesn't matter .
906+ BackendRepr :: SimdVector { .. } | BackendRepr :: Memory { .. } => true ,
900907 } ;
901908
902909 let src_val = if src_has_padding {
0 commit comments