Skip to content

Commit e68687b

Browse files
committed
test that we check the layout constraints as early as we can
1 parent 1d2877d commit e68687b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/compile-fail/nonzero.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![feature(rustc_attrs)]
2+
#![allow(unused_attributes)]
3+
4+
#[rustc_layout_scalar_valid_range_start(1)]
5+
#[repr(transparent)]
6+
pub(crate) struct NonZero<T>(pub(crate) T);
7+
8+
fn main() {
9+
// Make sure that we detect this even when no function call is happening along the way
10+
let _x = Some(NonZero(0)); //~ ERROR encountered 0, but expected something greater or equal to 1
11+
}

0 commit comments

Comments
 (0)