From f086b0ee77568e28fac7085866026a020758cee5 Mon Sep 17 00:00:00 2001 From: Kevin Reid Date: Wed, 5 Jun 2024 14:37:34 -0700 Subject: [PATCH] Remove unnecessary const blocks. --- compiler/rustc_data_structures/src/sip128.rs | 2 +- library/core/src/fmt/float.rs | 16 ++++++++-------- library/core/src/mem/maybe_uninit.rs | 2 +- library/core/src/net/display_buffer.rs | 2 +- library/std/src/fs/tests.rs | 2 +- library/std/src/net/tcp/tests.rs | 2 +- library/std/src/process/tests.rs | 2 +- library/std/src/sys/pal/windows/mod.rs | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_data_structures/src/sip128.rs b/compiler/rustc_data_structures/src/sip128.rs index a7e9868e38a58..fed23df10dcf4 100644 --- a/compiler/rustc_data_structures/src/sip128.rs +++ b/compiler/rustc_data_structures/src/sip128.rs @@ -188,7 +188,7 @@ impl SipHasher128 { pub fn new_with_keys(key0: u64, key1: u64) -> SipHasher128 { let mut hasher = SipHasher128 { nbuf: 0, - buf: [const { MaybeUninit::uninit() }; BUFFER_WITH_SPILL_CAPACITY], + buf: [MaybeUninit::uninit(); BUFFER_WITH_SPILL_CAPACITY], state: State { v0: key0 ^ 0x736f6d6570736575, // The XOR with 0xee is only done on 128-bit algorithm version. diff --git a/library/core/src/fmt/float.rs b/library/core/src/fmt/float.rs index e92aad6d7e49c..80c45fce2f0a0 100644 --- a/library/core/src/fmt/float.rs +++ b/library/core/src/fmt/float.rs @@ -35,8 +35,8 @@ fn float_to_decimal_common_exact( where T: flt2dec::DecodableFloat, { - let mut buf: [MaybeUninit; 1024] = [const { MaybeUninit::uninit() }; 1024]; // enough for f32 and f64 - let mut parts: [MaybeUninit>; 4] = [const { MaybeUninit::uninit() }; 4]; + let mut buf: [MaybeUninit; 1024] = [MaybeUninit::uninit(); 1024]; // enough for f32 and f64 + let mut parts: [MaybeUninit>; 4] = [MaybeUninit::uninit(); 4]; let formatted = flt2dec::to_exact_fixed_str( flt2dec::strategy::grisu::format_exact, *num, @@ -63,8 +63,8 @@ where { // enough for f32 and f64 let mut buf: [MaybeUninit; flt2dec::MAX_SIG_DIGITS] = - [const { MaybeUninit::uninit() }; flt2dec::MAX_SIG_DIGITS]; - let mut parts: [MaybeUninit>; 4] = [const { MaybeUninit::uninit() }; 4]; + [MaybeUninit::uninit(); flt2dec::MAX_SIG_DIGITS]; + let mut parts: [MaybeUninit>; 4] = [MaybeUninit::uninit(); 4]; let formatted = flt2dec::to_shortest_str( flt2dec::strategy::grisu::format_shortest, *num, @@ -108,8 +108,8 @@ fn float_to_exponential_common_exact( where T: flt2dec::DecodableFloat, { - let mut buf: [MaybeUninit; 1024] = [const { MaybeUninit::uninit() }; 1024]; // enough for f32 and f64 - let mut parts: [MaybeUninit>; 6] = [const { MaybeUninit::uninit() }; 6]; + let mut buf: [MaybeUninit; 1024] = [MaybeUninit::uninit(); 1024]; // enough for f32 and f64 + let mut parts: [MaybeUninit>; 6] = [MaybeUninit::uninit(); 6]; let formatted = flt2dec::to_exact_exp_str( flt2dec::strategy::grisu::format_exact, *num, @@ -137,8 +137,8 @@ where { // enough for f32 and f64 let mut buf: [MaybeUninit; flt2dec::MAX_SIG_DIGITS] = - [const { MaybeUninit::uninit() }; flt2dec::MAX_SIG_DIGITS]; - let mut parts: [MaybeUninit>; 6] = [const { MaybeUninit::uninit() }; 6]; + [MaybeUninit::uninit(); flt2dec::MAX_SIG_DIGITS]; + let mut parts: [MaybeUninit>; 6] = [MaybeUninit::uninit(); 6]; let formatted = flt2dec::to_shortest_exp_str( flt2dec::strategy::grisu::format_shortest, *num, diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs index e41590dcf1c4d..416192174ccb7 100644 --- a/library/core/src/mem/maybe_uninit.rs +++ b/library/core/src/mem/maybe_uninit.rs @@ -883,7 +883,7 @@ impl MaybeUninit { /// #![feature(maybe_uninit_array_assume_init)] /// use std::mem::MaybeUninit; /// - /// let mut array: [MaybeUninit; 3] = [const { MaybeUninit::uninit() }; 3]; + /// let mut array: [MaybeUninit; 3] = [MaybeUninit::uninit(); 3]; /// array[0].write(0); /// array[1].write(1); /// array[2].write(2); diff --git a/library/core/src/net/display_buffer.rs b/library/core/src/net/display_buffer.rs index 9eb03132e7a5a..6619c85f483ef 100644 --- a/library/core/src/net/display_buffer.rs +++ b/library/core/src/net/display_buffer.rs @@ -11,7 +11,7 @@ pub struct DisplayBuffer { impl DisplayBuffer { #[inline] pub const fn new() -> Self { - Self { buf: [const { MaybeUninit::uninit() }; SIZE], len: 0 } + Self { buf: [MaybeUninit::uninit(); SIZE], len: 0 } } #[inline] diff --git a/library/std/src/fs/tests.rs b/library/std/src/fs/tests.rs index 1a7e3ceef205b..b75579d6d5e01 100644 --- a/library/std/src/fs/tests.rs +++ b/library/std/src/fs/tests.rs @@ -406,7 +406,7 @@ fn file_test_read_buf() { let filename = &tmpdir.join("test"); check!(fs::write(filename, &[1, 2, 3, 4])); - let mut buf: [MaybeUninit; 128] = [const { MaybeUninit::uninit() }; 128]; + let mut buf: [MaybeUninit; 128] = [MaybeUninit::uninit(); 128]; let mut buf = BorrowedBuf::from(buf.as_mut_slice()); let mut file = check!(File::open(filename)); check!(file.read_buf(buf.unfilled())); diff --git a/library/std/src/net/tcp/tests.rs b/library/std/src/net/tcp/tests.rs index c21b1268a0f0a..3ad046733a634 100644 --- a/library/std/src/net/tcp/tests.rs +++ b/library/std/src/net/tcp/tests.rs @@ -301,7 +301,7 @@ fn read_buf() { }); let mut s = t!(srv.accept()).0; - let mut buf: [MaybeUninit; 128] = [const { MaybeUninit::uninit() }; 128]; + let mut buf: [MaybeUninit; 128] = [MaybeUninit::uninit(); 128]; let mut buf = BorrowedBuf::from(buf.as_mut_slice()); t!(s.read_buf(buf.unfilled())); assert_eq!(buf.filled(), &[1, 2, 3, 4]); diff --git a/library/std/src/process/tests.rs b/library/std/src/process/tests.rs index 3cff6e577c694..63455a274faaa 100644 --- a/library/std/src/process/tests.rs +++ b/library/std/src/process/tests.rs @@ -137,7 +137,7 @@ fn child_stdout_read_buf() { let child = cmd.spawn().unwrap(); let mut stdout = child.stdout.unwrap(); - let mut buf: [MaybeUninit; 128] = [const { MaybeUninit::uninit() }; 128]; + let mut buf: [MaybeUninit; 128] = [MaybeUninit::uninit(); 128]; let mut buf = BorrowedBuf::from(buf.as_mut_slice()); stdout.read_buf(buf.unfilled()).unwrap(); diff --git a/library/std/src/sys/pal/windows/mod.rs b/library/std/src/sys/pal/windows/mod.rs index ff195b1676c74..cd948d39f1496 100644 --- a/library/std/src/sys/pal/windows/mod.rs +++ b/library/std/src/sys/pal/windows/mod.rs @@ -227,7 +227,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; 512] = [const { MaybeUninit::uninit() }; 512]; + let mut stack_buf: [MaybeUninit; 512] = [MaybeUninit::uninit(); 512]; let mut heap_buf: Vec> = Vec::new(); unsafe { let mut n = stack_buf.len();