Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
CraftSpider committed Mar 2, 2023
1 parent 3a87a18 commit f26b0a2
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions compiler/rustc_middle/src/mir/interpret/allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ pub trait AllocBytes:

/// Create a zeroed `AllocBytes` of the specified size and alignment;
/// call the callback error handler if there is an error in allocating the memory.
fn zeroed(
size: Size,
_align: Align,
) -> Option<Self>;
fn zeroed(size: Size, _align: Align) -> Option<Self>;
}

// Default `bytes` for `Allocation` is a `Box<[u8]>`.
Expand All @@ -58,10 +55,7 @@ impl AllocBytes for Box<[u8]> {
Box::<[u8]>::from(slice.into())
}

fn zeroed(
size: Size,
_align: Align,
) -> Option<Self> {
fn zeroed(size: Size, _align: Align) -> Option<Self> {
let bytes = Box::<[u8]>::try_new_zeroed_slice(size.bytes_usize()).ok()?;
// SAFETY: the box was zero-allocated, which is a valid initial value for Box<[u8]>
let bytes = unsafe { bytes.assume_init() };
Expand Down

0 comments on commit f26b0a2

Please sign in to comment.