diff options
| author | Michael Goulet <michael@errs.io> | 2024-06-24 15:51:01 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-24 15:51:01 -0400 |
| commit | c77dc28f87029a0cb2a505dfb70f9fc59a4b3119 (patch) | |
| tree | bb9a7c84fab16f0a1f23c263cec168053b2f2f84 /library/std/src/sys | |
| parent | faa28be2f14b94148a19e1d4023b0a18f9b4d16a (diff) | |
| parent | 13fca73f4937fe4bb318321525a0fd666e9da16e (diff) | |
| download | rust-c77dc28f87029a0cb2a505dfb70f9fc59a4b3119.tar.gz rust-c77dc28f87029a0cb2a505dfb70f9fc59a4b3119.zip | |
Rollup merge of #125082 - kpreid:const-uninit, r=dtolnay
Remove `MaybeUninit::uninit_array()` and replace it with inline const blocks.
\[This PR originally contained the changes in #125995 too. See edit history for the original PR description.]
The documentation of `MaybeUninit::uninit_array()` says:
> 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];`.
The PR adding it also said: <https://github.com/rust-lang/rust/pull/65580#issuecomment-544200681>
> if it’s stabilized soon enough maybe it’s not worth having a standard library method that will be replaceable with `let buffer = [MaybeUninit::<T>::uninit(); $N];`
That time has come to pass — inline const expressions are stable — so `MaybeUninit::uninit_array()` is now unnecessary. The only remaining question is whether it is an important enough *convenience* to keep it around.
I believe it is net good to remove this function, on the principle that it is better to compose two orthogonal features (`MaybeUninit` and array construction) than to have a specific function for the specific combination, now that that is possible.
Diffstat (limited to 'library/std/src/sys')
| -rw-r--r-- | library/std/src/sys/pal/windows/mod.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/library/std/src/sys/pal/windows/mod.rs b/library/std/src/sys/pal/windows/mod.rs index a1bc2965e2e..6406cec9c27 100644 --- a/library/std/src/sys/pal/windows/mod.rs +++ b/library/std/src/sys/pal/windows/mod.rs @@ -225,7 +225,7 @@ where // This initial size also works around `GetFullPathNameW` returning // incorrect size hints for some short paths: // https://github.com/dylni/normpath/issues/5 - let mut stack_buf: [MaybeUninit<u16>; 512] = MaybeUninit::uninit_array(); + let mut stack_buf: [MaybeUninit<u16>; 512] = [MaybeUninit::uninit(); 512]; let mut heap_buf: Vec<MaybeUninit<u16>> = Vec::new(); unsafe { let mut n = stack_buf.len(); |
