]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/validity/nonzero.rs
Auto merge of #103020 - lyming2007:issue-102598-fix, r=jackh726
[rust.git] / src / tools / miri / tests / fail / validity / nonzero.rs
1 // gets masked by optimizations
2 //@compile-flags: -Zmir-opt-level=0
3 #![feature(rustc_attrs)]
4 #![allow(unused_attributes)]
5
6 #[rustc_layout_scalar_valid_range_start(1)]
7 #[repr(transparent)]
8 pub(crate) struct NonZero<T>(pub(crate) T);
9
10 fn main() {
11     // Make sure that we detect this even when no function call is happening along the way
12     let _x = Some(unsafe { NonZero(0) }); //~ ERROR: encountered 0, but expected something greater or equal to 1
13 }