Skip to content

Commit 9b86a71

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 2857b6f commit 9b86a71

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

core/src/alloc/layout.rs

Lines changed: 3 additions & 1 deletion
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)