Skip to content

Commit ea50b43

Browse files
authored
Rollup merge of rust-lang#134585 - cyrgani:uninit_array, r=Amanieu
remove `MaybeUninit::uninit_array` Closes rust-lang#134584. Closes rust-lang#66845. The future of this unstable method was described in rust-lang#125082 (comment). Since `inline_const` was stabilized in 1.79 (4 stable releases away) and no one expressed interest for keeping it in rust-lang#96097, I think it can be removed now as it is not a stable method.
2 parents af61cb5 + 4f6a457 commit ea50b43

File tree

1 file changed

+0
-36
lines changed

1 file changed

+0
-36
lines changed

core/src/mem/maybe_uninit.rs

-36
Original file line numberDiff line numberDiff line change
@@ -331,42 +331,6 @@ impl<T> MaybeUninit<T> {
331331
MaybeUninit { uninit: () }
332332
}
333333

334-
/// Creates a new array of `MaybeUninit<T>` items, in an uninitialized state.
335-
///
336-
/// Note: in a future Rust version this method may become unnecessary
337-
/// when Rust allows
338-
/// [inline const expressions](https://github.com/rust-lang/rust/issues/76001).
339-
/// The example below could then use `let mut buf = [const { MaybeUninit::<u8>::uninit() }; 32];`.
340-
///
341-
/// # Examples
342-
///
343-
/// ```no_run
344-
/// #![feature(maybe_uninit_uninit_array, maybe_uninit_slice)]
345-
///
346-
/// use std::mem::MaybeUninit;
347-
///
348-
/// unsafe extern "C" {
349-
/// fn read_into_buffer(ptr: *mut u8, max_len: usize) -> usize;
350-
/// }
351-
///
352-
/// /// Returns a (possibly smaller) slice of data that was actually read
353-
/// fn read(buf: &mut [MaybeUninit<u8>]) -> &[u8] {
354-
/// unsafe {
355-
/// let len = read_into_buffer(buf.as_mut_ptr() as *mut u8, buf.len());
356-
/// buf[..len].assume_init_ref()
357-
/// }
358-
/// }
359-
///
360-
/// let mut buf: [MaybeUninit<u8>; 32] = MaybeUninit::uninit_array();
361-
/// let data = read(&mut buf);
362-
/// ```
363-
#[unstable(feature = "maybe_uninit_uninit_array", issue = "96097")]
364-
#[must_use]
365-
#[inline(always)]
366-
pub const fn uninit_array<const N: usize>() -> [Self; N] {
367-
[const { MaybeUninit::uninit() }; N]
368-
}
369-
370334
/// Creates a new `MaybeUninit<T>` in an uninitialized state, with the memory being
371335
/// filled with `0` bytes. It depends on `T` whether that already makes for
372336
/// proper initialization. For example, `MaybeUninit<usize>::zeroed()` is initialized,

0 commit comments

Comments
 (0)