Rollup merge of #103163 - SUPERCILEX:uninit-array-assume2, r=scottmcm
Remove all uses of array_assume_init See https://github.com/rust-lang/rust/pull/103134#discussion_r997462733 r? `@scottmcm`
This commit is contained in:
commit
b411b8861c
@ -125,9 +125,9 @@
|
||||
#![feature(iter_advance_by)]
|
||||
#![feature(iter_next_chunk)]
|
||||
#![feature(layout_for_ptr)]
|
||||
#![feature(maybe_uninit_array_assume_init)]
|
||||
#![feature(maybe_uninit_slice)]
|
||||
#![feature(maybe_uninit_uninit_array)]
|
||||
#![feature(maybe_uninit_uninit_array_transpose)]
|
||||
#![cfg_attr(test, feature(new_uninit))]
|
||||
#![feature(nonnull_slice_from_raw_parts)]
|
||||
#![feature(pattern)]
|
||||
|
@ -223,7 +223,7 @@ fn count(self) -> usize {
|
||||
|
||||
self.ptr = self.ptr.wrapping_byte_add(N);
|
||||
// Safety: ditto
|
||||
return Ok(unsafe { MaybeUninit::array_assume_init(raw_ary) });
|
||||
return Ok(unsafe { raw_ary.transpose().assume_init() });
|
||||
}
|
||||
|
||||
if len < N {
|
||||
@ -241,7 +241,7 @@ fn count(self) -> usize {
|
||||
return unsafe {
|
||||
ptr::copy_nonoverlapping(self.ptr, raw_ary.as_mut_ptr() as *mut T, N);
|
||||
self.ptr = self.ptr.add(N);
|
||||
Ok(MaybeUninit::array_assume_init(raw_ary))
|
||||
Ok(raw_ary.transpose().assume_init())
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -104,8 +104,7 @@ impl<T, const N: usize> IntoIter<T, N> {
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(array_into_iter_constructors)]
|
||||
///
|
||||
/// #![feature(maybe_uninit_array_assume_init)]
|
||||
/// #![feature(maybe_uninit_uninit_array_transpose)]
|
||||
/// #![feature(maybe_uninit_uninit_array)]
|
||||
/// use std::array::IntoIter;
|
||||
/// use std::mem::MaybeUninit;
|
||||
@ -134,7 +133,7 @@ impl<T, const N: usize> IntoIter<T, N> {
|
||||
/// }
|
||||
///
|
||||
/// // SAFETY: We've initialized all N items
|
||||
/// unsafe { Ok(MaybeUninit::array_assume_init(buffer)) }
|
||||
/// unsafe { Ok(buffer.transpose().assume_init()) }
|
||||
/// }
|
||||
///
|
||||
/// let r: [_; 4] = next_chunk(&mut (10..16)).unwrap();
|
||||
|
@ -912,7 +912,7 @@ fn drop(&mut self) {
|
||||
|
||||
mem::forget(guard);
|
||||
// SAFETY: All elements of the array were populated in the loop above.
|
||||
let output = unsafe { MaybeUninit::array_assume_init(array) };
|
||||
let output = unsafe { array.transpose().assume_init() };
|
||||
Ok(Try::from_output(output))
|
||||
}
|
||||
|
||||
|
@ -49,8 +49,8 @@
|
||||
#![feature(slice_from_ptr_range)]
|
||||
#![feature(split_as_slice)]
|
||||
#![feature(maybe_uninit_uninit_array)]
|
||||
#![feature(maybe_uninit_array_assume_init)]
|
||||
#![feature(maybe_uninit_write_slice)]
|
||||
#![feature(maybe_uninit_uninit_array_transpose)]
|
||||
#![feature(min_specialization)]
|
||||
#![feature(numfmt)]
|
||||
#![feature(step_trait)]
|
||||
|
@ -163,18 +163,18 @@ fn assume_init_good() {
|
||||
|
||||
#[test]
|
||||
fn uninit_array_assume_init() {
|
||||
let mut array: [MaybeUninit<i16>; 5] = MaybeUninit::uninit_array();
|
||||
let mut array = [MaybeUninit::<i16>::uninit(); 5];
|
||||
array[0].write(3);
|
||||
array[1].write(1);
|
||||
array[2].write(4);
|
||||
array[3].write(1);
|
||||
array[4].write(5);
|
||||
|
||||
let array = unsafe { MaybeUninit::array_assume_init(array) };
|
||||
let array = unsafe { array.transpose().assume_init() };
|
||||
|
||||
assert_eq!(array, [3, 1, 4, 1, 5]);
|
||||
|
||||
let [] = unsafe { MaybeUninit::<!>::array_assume_init([]) };
|
||||
let [] = unsafe { [MaybeUninit::<!>::uninit(); 0].transpose().assume_init() };
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
Reference in New Issue
Block a user