17
17
//! stable sorting implementation.
18
18
19
19
use cmp;
20
- use mem;
20
+ use mem:: { self , MaybeUninit } ;
21
21
use ptr;
22
22
23
23
/// When dropped, copies from `src` into `dest`.
@@ -226,14 +226,14 @@ fn partition_in_blocks<T, F>(v: &mut [T], pivot: &T, is_less: &mut F) -> usize
226
226
let mut block_l = BLOCK ;
227
227
let mut start_l = ptr:: null_mut ( ) ;
228
228
let mut end_l = ptr:: null_mut ( ) ;
229
- let mut offsets_l: [ u8 ; BLOCK ] = unsafe { mem :: uninitialized ( ) } ;
229
+ let mut offsets_l = MaybeUninit :: < [ u8 ; BLOCK ] > :: uninitialized ( ) ;
230
230
231
231
// The current block on the right side (from `r.sub(block_r)` to `r`).
232
232
let mut r = unsafe { l. add ( v. len ( ) ) } ;
233
233
let mut block_r = BLOCK ;
234
234
let mut start_r = ptr:: null_mut ( ) ;
235
235
let mut end_r = ptr:: null_mut ( ) ;
236
- let mut offsets_r: [ u8 ; BLOCK ] = unsafe { mem :: uninitialized ( ) } ;
236
+ let mut offsets_r = MaybeUninit :: < [ u8 ; BLOCK ] > :: uninitialized ( ) ;
237
237
238
238
// FIXME: When we get VLAs, try creating one array of length `min(v.len(), 2 * BLOCK)` rather
239
239
// than two fixed-size arrays of length `BLOCK`. VLAs might be more cache-efficient.
@@ -272,8 +272,8 @@ fn partition_in_blocks<T, F>(v: &mut [T], pivot: &T, is_less: &mut F) -> usize
272
272
273
273
if start_l == end_l {
274
274
// Trace `block_l` elements from the left side.
275
- start_l = offsets_l. as_mut_ptr ( ) ;
276
- end_l = offsets_l. as_mut_ptr ( ) ;
275
+ start_l = offsets_l. as_mut_ptr ( ) as * mut u8 ;
276
+ end_l = offsets_l. as_mut_ptr ( ) as * mut u8 ;
277
277
let mut elem = l;
278
278
279
279
for i in 0 ..block_l {
@@ -288,8 +288,8 @@ fn partition_in_blocks<T, F>(v: &mut [T], pivot: &T, is_less: &mut F) -> usize
288
288
289
289
if start_r == end_r {
290
290
// Trace `block_r` elements from the right side.
291
- start_r = offsets_r. as_mut_ptr ( ) ;
292
- end_r = offsets_r. as_mut_ptr ( ) ;
291
+ start_r = offsets_r. as_mut_ptr ( ) as * mut u8 ;
292
+ end_r = offsets_r. as_mut_ptr ( ) as * mut u8 ;
293
293
let mut elem = r;
294
294
295
295
for i in 0 ..block_r {
0 commit comments