@@ -177,6 +177,8 @@ fn small_sort_fallback<T, F: FnMut(&T, &T) -> bool>(v: &mut [T], is_less: &mut F
177177fn small_sort_general < T : FreezeMarker , F : FnMut ( & T , & T ) -> bool > ( v : & mut [ T ] , is_less : & mut F ) {
178178 let mut stack_array = MaybeUninit :: < [ T ; SMALL_SORT_GENERAL_SCRATCH_LEN ] > :: uninit ( ) ;
179179
180+ // SAFETY: The memory is backed by `stack_array`, and the operation is safe as long as the len
181+ // is the same.
180182 let scratch = unsafe {
181183 slice:: from_raw_parts_mut (
182184 stack_array. as_mut_ptr ( ) as * mut MaybeUninit < T > ,
@@ -327,8 +329,9 @@ where
327329 }
328330
329331 // 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+ } ;
332335 }
333336
334337 // 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 {
812815 mem:: size_of :: < T > ( ) <= 8 // mem::size_of::<u64>()
813816}
814817
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-
823818/// SAFETY: Only used for run-time optimization heuristic.
824819#[ rustc_unsafe_specialization_marker]
825820trait CopyMarker { }
0 commit comments