]> git.lizzy.rs Git - rust.git/blob - tests/ui/unsafe/ranged_ints_const.rs
Merge commit '1d8491b120223272b13451fc81265aa64f7f4d5b' into sync-from-rustfmt
[rust.git] / tests / ui / unsafe / ranged_ints_const.rs
1 // revisions: mir thir
2 // [thir]compile-flags: -Z thir-unsafeck
3
4 #![feature(rustc_attrs)]
5
6 #[rustc_layout_scalar_valid_range_start(1)]
7 #[repr(transparent)]
8 pub(crate) struct NonZero<T>(pub(crate) T);
9 fn main() {}
10
11 const fn foo() -> NonZero<u32> { NonZero(0) }
12 //~^ ERROR initializing type with `rustc_layout_scalar_valid_range` attr is unsafe
13
14 const fn bar() -> NonZero<u32> { unsafe { NonZero(0) } }