Skip to content

Commit 6b7f6b9

Browse files
committed
remove no-longer-needed work-arounds from the standard library
1 parent eb4bdb0 commit 6b7f6b9

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

library/core/src/mem/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -730,10 +730,7 @@ pub const fn swap<T>(x: &mut T, y: &mut T) {
730730
// understanding `mem::replace`, `Option::take`, etc. - a better overall
731731
// solution might be to make `ptr::swap_nonoverlapping` into an intrinsic, which
732732
// a backend can choose to implement using the block optimization, or not.
733-
// NOTE(scottmcm) MIRI is disabled here as reading in smaller units is a
734-
// pessimization for it. Also, if the type contains any unaligned pointers,
735-
// copying those over multiple reads is difficult to support.
736-
#[cfg(not(any(target_arch = "spirv", miri)))]
733+
#[cfg(not(any(target_arch = "spirv")))]
737734
{
738735
// For types that are larger multiples of their alignment, the simple way
739736
// tends to copy the whole thing to stack rather than doing it one part

library/core/src/ptr/mod.rs

+8-14
Original file line numberDiff line numberDiff line change
@@ -908,21 +908,15 @@ pub const unsafe fn swap_nonoverlapping<T>(x: *mut T, y: *mut T, count: usize) {
908908
);
909909
}
910910

911-
// NOTE(scottmcm) Miri is disabled here as reading in smaller units is a
912-
// pessimization for it. Also, if the type contains any unaligned pointers,
913-
// copying those over multiple reads is difficult to support.
914-
#[cfg(not(miri))]
911+
// Split up the slice into small power-of-two-sized chunks that LLVM is able
912+
// to vectorize (unless it's a special type with more-than-pointer alignment,
913+
// because we don't want to pessimize things like slices of SIMD vectors.)
914+
if mem::align_of::<T>() <= mem::size_of::<usize>()
915+
&& (!mem::size_of::<T>().is_power_of_two()
916+
|| mem::size_of::<T>() > mem::size_of::<usize>() * 2)
915917
{
916-
// Split up the slice into small power-of-two-sized chunks that LLVM is able
917-
// to vectorize (unless it's a special type with more-than-pointer alignment,
918-
// because we don't want to pessimize things like slices of SIMD vectors.)
919-
if mem::align_of::<T>() <= mem::size_of::<usize>()
920-
&& (!mem::size_of::<T>().is_power_of_two()
921-
|| mem::size_of::<T>() > mem::size_of::<usize>() * 2)
922-
{
923-
attempt_swap_as_chunks!(usize);
924-
attempt_swap_as_chunks!(u8);
925-
}
918+
attempt_swap_as_chunks!(usize);
919+
attempt_swap_as_chunks!(u8);
926920
}
927921

928922
// SAFETY: Same preconditions as this function

0 commit comments

Comments
 (0)