@@ -177,6 +177,8 @@ fn small_sort_fallback<T, F: FnMut(&T, &T) -> bool>(v: &mut [T], is_less: &mut F
177
177
fn small_sort_general < T : FreezeMarker , F : FnMut ( & T , & T ) -> bool > ( v : & mut [ T ] , is_less : & mut F ) {
178
178
let mut stack_array = MaybeUninit :: < [ T ; SMALL_SORT_GENERAL_SCRATCH_LEN ] > :: uninit ( ) ;
179
179
180
+ // SAFETY: The memory is backed by `stack_array`, and the operation is safe as long as the len
181
+ // is the same.
180
182
let scratch = unsafe {
181
183
slice:: from_raw_parts_mut (
182
184
stack_array. as_mut_ptr ( ) as * mut MaybeUninit < T > ,
@@ -327,8 +329,9 @@ where
327
329
}
328
330
329
331
// SAFETY: The right side of `v` based on `len_div_2` is guaranteed in-bounds.
330
- region =
331
- unsafe { & mut * ptr:: slice_from_raw_parts_mut ( v_base. add ( len_div_2) , len - len_div_2) } ;
332
+ unsafe {
333
+ region = & mut * ptr:: slice_from_raw_parts_mut ( v_base. add ( len_div_2) , len - len_div_2)
334
+ } ;
332
335
}
333
336
334
337
// SAFETY: We checked that T is Freeze and thus observation safe.
@@ -812,14 +815,6 @@ pub(crate) const fn has_efficient_in_place_swap<T>() -> bool {
812
815
mem:: size_of :: < T > ( ) <= 8 // mem::size_of::<u64>()
813
816
}
814
817
815
- #[ test]
816
- fn type_info ( ) {
817
- assert ! ( has_efficient_in_place_swap:: <i32 >( ) ) ;
818
- assert ! ( has_efficient_in_place_swap:: <u64 >( ) ) ;
819
- assert ! ( !has_efficient_in_place_swap:: <u128 >( ) ) ;
820
- assert ! ( !has_efficient_in_place_swap:: <String >( ) ) ;
821
- }
822
-
823
818
/// SAFETY: Only used for run-time optimization heuristic.
824
819
#[ rustc_unsafe_specialization_marker]
825
820
trait CopyMarker { }
0 commit comments