From: Richard Wiedenhöft Date: Tue, 30 Apr 2019 06:23:14 +0000 (+0200) Subject: Add const_unchecked_layout test to libcore/tests X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=07e8d844795628ce90415c1dec3536f3e75cc71c;p=rust.git Add const_unchecked_layout test to libcore/tests --- diff --git a/src/libcore/tests/alloc.rs b/src/libcore/tests/alloc.rs new file mode 100644 index 00000000000..63537ba23d8 --- /dev/null +++ b/src/libcore/tests/alloc.rs @@ -0,0 +1,10 @@ +use core::alloc::Layout; + +#[test] +fn const_unchecked_layout() { + const SIZE: usize = 0x2000; + const ALIGN: usize = 0x1000; + const LAYOUT: Layout = unsafe { Layout::from_size_align_unchecked(SIZE, ALIGN) }; + assert_eq!(LAYOUT.size(), SIZE); + assert_eq!(LAYOUT.align(), ALIGN); +} diff --git a/src/libcore/tests/lib.rs b/src/libcore/tests/lib.rs index b8075ef2942..c617596aba8 100644 --- a/src/libcore/tests/lib.rs +++ b/src/libcore/tests/lib.rs @@ -31,10 +31,12 @@ #![feature(slice_partition_dedup)] #![feature(copy_within)] #![feature(int_error_matching)] +#![feature(const_fn)] #![warn(rust_2018_idioms)] extern crate test; +mod alloc; mod any; mod array; mod ascii;