Skip to content

Commit 026edbb

Browse files
committed
Use unchecked construction in Layout::pad_to_align.
Other, similar methods for `Layout` do likewise, and there's already an `unwrap()` around the result demonstrating the safety.
1 parent 8a48b37 commit 026edbb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

library/core/src/alloc/layout.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,9 @@ impl Layout {
281281
// > `usize::MAX`)
282282
let new_size = self.size() + pad;
283283

284-
Layout::from_size_align(new_size, self.align()).unwrap()
284+
// SAFETY: self.align is already known to be valid and new_size has been
285+
// padded already.
286+
unsafe { Layout::from_size_align_unchecked(new_size, self.align()) }
285287
}
286288

287289
/// Creates a layout describing the record for `n` instances of

0 commit comments

Comments
 (0)