File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -732,7 +732,7 @@ pub const fn swap<T>(x: &mut T, y: &mut T) {
732732 // tends to copy the whole thing to stack rather than doing it one part
733733 // at a time, so instead treat them as one-element slices and piggy-back
734734 // the slice optimizations that will split up the swaps.
735- if size_of :: < T > ( ) / align_of :: < T > ( ) > 4 {
735+ if T :: IS_BIG_SWAP {
736736 // SAFETY: exclusive references always point to one non-overlapping
737737 // element and are non-null and properly aligned.
738738 return unsafe { ptr:: swap_nonoverlapping ( x, y, 1 ) } ;
@@ -1273,3 +1273,9 @@ pub trait SizedTypeProperties: Sized {
12731273#[ doc( hidden) ]
12741274#[ unstable( feature = "sized_type_properties" , issue = "none" ) ]
12751275impl < T > SizedTypeProperties for T { }
1276+
1277+ trait InternalSizedTypeProperties : Sized {
1278+ const IS_BIG_SWAP : bool = size_of :: < Self > ( ) / align_of :: < Self > ( ) > 4 ;
1279+ }
1280+
1281+ impl < T > InternalSizedTypeProperties for T { }
You can’t perform that action at this time.
0 commit comments