Skip to content

Commit 07e8d84

Browse files
committed
Add const_unchecked_layout test to libcore/tests
1 parent a7a0520 commit 07e8d84

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Diff for: src/libcore/tests/alloc.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use core::alloc::Layout;
2+
3+
#[test]
4+
fn const_unchecked_layout() {
5+
const SIZE: usize = 0x2000;
6+
const ALIGN: usize = 0x1000;
7+
const LAYOUT: Layout = unsafe { Layout::from_size_align_unchecked(SIZE, ALIGN) };
8+
assert_eq!(LAYOUT.size(), SIZE);
9+
assert_eq!(LAYOUT.align(), ALIGN);
10+
}

Diff for: src/libcore/tests/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@
3131
#![feature(slice_partition_dedup)]
3232
#![feature(copy_within)]
3333
#![feature(int_error_matching)]
34+
#![feature(const_fn)]
3435
#![warn(rust_2018_idioms)]
3536

3637
extern crate test;
3738

39+
mod alloc;
3840
mod any;
3941
mod array;
4042
mod ascii;

0 commit comments

Comments
 (0)