Skip to content

Commit

Permalink
Remove unnecessary const blocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
kpreid committed Jun 5, 2024
1 parent d1c71d6 commit f086b0e
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_data_structures/src/sip128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 8 additions & 8 deletions library/core/src/fmt/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ fn float_to_decimal_common_exact<T>(
where
T: flt2dec::DecodableFloat,
{
let mut buf: [MaybeUninit<u8>; 1024] = [const { MaybeUninit::uninit() }; 1024]; // enough for f32 and f64
let mut parts: [MaybeUninit<numfmt::Part<'_>>; 4] = [const { MaybeUninit::uninit() }; 4];
let mut buf: [MaybeUninit<u8>; 1024] = [MaybeUninit::uninit(); 1024]; // enough for f32 and f64
let mut parts: [MaybeUninit<numfmt::Part<'_>>; 4] = [MaybeUninit::uninit(); 4];
let formatted = flt2dec::to_exact_fixed_str(
flt2dec::strategy::grisu::format_exact,
*num,
Expand All @@ -63,8 +63,8 @@ where
{
// enough for f32 and f64
let mut buf: [MaybeUninit<u8>; flt2dec::MAX_SIG_DIGITS] =
[const { MaybeUninit::uninit() }; flt2dec::MAX_SIG_DIGITS];
let mut parts: [MaybeUninit<numfmt::Part<'_>>; 4] = [const { MaybeUninit::uninit() }; 4];
[MaybeUninit::uninit(); flt2dec::MAX_SIG_DIGITS];
let mut parts: [MaybeUninit<numfmt::Part<'_>>; 4] = [MaybeUninit::uninit(); 4];
let formatted = flt2dec::to_shortest_str(
flt2dec::strategy::grisu::format_shortest,
*num,
Expand Down Expand Up @@ -108,8 +108,8 @@ fn float_to_exponential_common_exact<T>(
where
T: flt2dec::DecodableFloat,
{
let mut buf: [MaybeUninit<u8>; 1024] = [const { MaybeUninit::uninit() }; 1024]; // enough for f32 and f64
let mut parts: [MaybeUninit<numfmt::Part<'_>>; 6] = [const { MaybeUninit::uninit() }; 6];
let mut buf: [MaybeUninit<u8>; 1024] = [MaybeUninit::uninit(); 1024]; // enough for f32 and f64
let mut parts: [MaybeUninit<numfmt::Part<'_>>; 6] = [MaybeUninit::uninit(); 6];
let formatted = flt2dec::to_exact_exp_str(
flt2dec::strategy::grisu::format_exact,
*num,
Expand Down Expand Up @@ -137,8 +137,8 @@ where
{
// enough for f32 and f64
let mut buf: [MaybeUninit<u8>; flt2dec::MAX_SIG_DIGITS] =
[const { MaybeUninit::uninit() }; flt2dec::MAX_SIG_DIGITS];
let mut parts: [MaybeUninit<numfmt::Part<'_>>; 6] = [const { MaybeUninit::uninit() }; 6];
[MaybeUninit::uninit(); flt2dec::MAX_SIG_DIGITS];
let mut parts: [MaybeUninit<numfmt::Part<'_>>; 6] = [MaybeUninit::uninit(); 6];
let formatted = flt2dec::to_shortest_exp_str(
flt2dec::strategy::grisu::format_shortest,
*num,
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/mem/maybe_uninit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ impl<T> MaybeUninit<T> {
/// #![feature(maybe_uninit_array_assume_init)]
/// use std::mem::MaybeUninit;
///
/// let mut array: [MaybeUninit<i32>; 3] = [const { MaybeUninit::uninit() }; 3];
/// let mut array: [MaybeUninit<i32>; 3] = [MaybeUninit::uninit(); 3];
/// array[0].write(0);
/// array[1].write(1);
/// array[2].write(2);
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/net/display_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub struct DisplayBuffer<const SIZE: usize> {
impl<const SIZE: usize> DisplayBuffer<SIZE> {
#[inline]
pub const fn new() -> Self {
Self { buf: [const { MaybeUninit::uninit() }; SIZE], len: 0 }
Self { buf: [MaybeUninit::uninit(); SIZE], len: 0 }
}

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/fs/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>; 128] = [const { MaybeUninit::uninit() }; 128];
let mut buf: [MaybeUninit<u8>; 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()));
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/net/tcp/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ fn read_buf() {
});

let mut s = t!(srv.accept()).0;
let mut buf: [MaybeUninit<u8>; 128] = [const { MaybeUninit::uninit() }; 128];
let mut buf: [MaybeUninit<u8>; 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]);
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/process/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ fn child_stdout_read_buf() {
let child = cmd.spawn().unwrap();

let mut stdout = child.stdout.unwrap();
let mut buf: [MaybeUninit<u8>; 128] = [const { MaybeUninit::uninit() }; 128];
let mut buf: [MaybeUninit<u8>; 128] = [MaybeUninit::uninit(); 128];
let mut buf = BorrowedBuf::from(buf.as_mut_slice());
stdout.read_buf(buf.unfilled()).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/pal/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u16>; 512] = [const { MaybeUninit::uninit() }; 512];
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();
Expand Down

0 comments on commit f086b0e

Please sign in to comment.