From 183e61b66174e76520b38cf5153f8fb6f5cdce94 Mon Sep 17 00:00:00 2001 From: Christopher Durham Date: Sat, 9 Nov 2019 15:28:32 -0500 Subject: [PATCH] Fix Layout::pad_to_align type mismatch --- src/libcore/alloc.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libcore/alloc.rs b/src/libcore/alloc.rs index c6d18b04a31d..7d621090f07a 100644 --- a/src/libcore/alloc.rs +++ b/src/libcore/alloc.rs @@ -224,9 +224,10 @@ impl Layout { // > must not overflow (i.e., the rounded value must be less than // > `usize::MAX`) let new_size = self.size() + pad; - debug_assert!(new_size > self.size()); - Layout::from_size_align(new_size, self.align()) + // SAFETY: This necessarily respectes the from_size_align + // prerequisites per the above. + unsafe { Layout::from_size_align_unchecked(new_size, self.align()) } } /// Creates a layout describing the record for `n` instances of