Skip to content

Commit

Permalink
Unrolled build for rust-lang#134585
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rust-timer authored Feb 26, 2025
2 parents ac91805 + f0a6af0 commit 1addd61
Showing 1 changed file with 0 additions and 36 deletions.
36 changes: 0 additions & 36 deletions library/core/src/mem/maybe_uninit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,42 +331,6 @@ impl<T> MaybeUninit<T> {
MaybeUninit { uninit: () }
}

/// Creates a new array of `MaybeUninit<T>` items, in an uninitialized state.
///
/// Note: in a future Rust version this method may become unnecessary
/// when Rust allows
/// [inline const expressions](https://github.com/rust-lang/rust/issues/76001).
/// The example below could then use `let mut buf = [const { MaybeUninit::<u8>::uninit() }; 32];`.
///
/// # Examples
///
/// ```no_run
/// #![feature(maybe_uninit_uninit_array, maybe_uninit_slice)]
///
/// use std::mem::MaybeUninit;
///
/// unsafe extern "C" {
/// fn read_into_buffer(ptr: *mut u8, max_len: usize) -> usize;
/// }
///
/// /// Returns a (possibly smaller) slice of data that was actually read
/// fn read(buf: &mut [MaybeUninit<u8>]) -> &[u8] {
/// unsafe {
/// let len = read_into_buffer(buf.as_mut_ptr() as *mut u8, buf.len());
/// buf[..len].assume_init_ref()
/// }
/// }
///
/// let mut buf: [MaybeUninit<u8>; 32] = MaybeUninit::uninit_array();
/// let data = read(&mut buf);
/// ```
#[unstable(feature = "maybe_uninit_uninit_array", issue = "96097")]
#[must_use]
#[inline(always)]
pub const fn uninit_array<const N: usize>() -> [Self; N] {
[const { MaybeUninit::uninit() }; N]
}

/// Creates a new `MaybeUninit<T>` in an uninitialized state, with the memory being
/// filled with `0` bytes. It depends on `T` whether that already makes for
/// proper initialization. For example, `MaybeUninit<usize>::zeroed()` is initialized,
Expand Down

0 comments on commit 1addd61

Please sign in to comment.