about summary refs log tree commit diff
path: root/src/libcore/alloc/layout.rs
diff options
context:
space:
mode:
authorLeSeulArtichaut <leseulartichaut@gmail.com>2020-06-22 00:54:46 +0200
committerLeSeulArtichaut <leseulartichaut@gmail.com>2020-06-30 16:42:57 +0200
commit8ee1dec77b89d6341a147d91af8733f8e0b5efc7 (patch)
treeebb689b9d02af4dc8d9032f024ea4d9323061f4e /src/libcore/alloc/layout.rs
parent665190b34609c5204a3bd57c571c1dff4d8bc5f2 (diff)
downloadrust-8ee1dec77b89d6341a147d91af8733f8e0b5efc7.tar.gz
rust-8ee1dec77b89d6341a147d91af8733f8e0b5efc7.zip
Deny unsafe ops in unsafe fns, part 1
Diffstat (limited to 'src/libcore/alloc/layout.rs')
-rw-r--r--src/libcore/alloc/layout.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libcore/alloc/layout.rs b/src/libcore/alloc/layout.rs
index a09c2387d0d..ae7ae704465 100644
--- a/src/libcore/alloc/layout.rs
+++ b/src/libcore/alloc/layout.rs
@@ -90,7 +90,8 @@ impl Layout {
     #[rustc_const_stable(feature = "alloc_layout", since = "1.28.0")]
     #[inline]
     pub const unsafe fn from_size_align_unchecked(size: usize, align: usize) -> Self {
-        Layout { size_: size, align_: NonZeroUsize::new_unchecked(align) }
+        // SAFETY: the caller must ensure that `align` is greater than zero.
+        Layout { size_: size, align_: unsafe { NonZeroUsize::new_unchecked(align) } }
     }
 
     /// The minimum size in bytes for a memory block of this layout.