diff options
Diffstat (limited to 'tests/ui/consts/const-eval/valid-const.rs')
-rw-r--r-- | tests/ui/consts/const-eval/valid-const.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/ui/consts/const-eval/valid-const.rs b/tests/ui/consts/const-eval/valid-const.rs new file mode 100644 index 000000000..5f47d1c4f --- /dev/null +++ b/tests/ui/consts/const-eval/valid-const.rs @@ -0,0 +1,17 @@ +// check-pass + +// Some constants that *are* valid + +use std::mem; +use std::ptr::NonNull; +use std::num::{NonZeroU8, NonZeroUsize}; + +const NON_NULL_PTR1: NonNull<u8> = unsafe { mem::transmute(1usize) }; +const NON_NULL_PTR2: NonNull<u8> = unsafe { mem::transmute(&0) }; + +const NON_NULL_U8: NonZeroU8 = unsafe { mem::transmute(1u8) }; +const NON_NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(1usize) }; + +const UNIT: () = (); + +fn main() {} |