From 95593331bfac293478582c2945b7106225500743 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 3 Oct 2018 09:06:35 +0200 Subject: [PATCH] add some tests with constants that better be valid --- src/test/ui/consts/const-eval/valid-const.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/test/ui/consts/const-eval/valid-const.rs diff --git a/src/test/ui/consts/const-eval/valid-const.rs b/src/test/ui/consts/const-eval/valid-const.rs new file mode 100644 index 00000000000..a195e12defc --- /dev/null +++ b/src/test/ui/consts/const-eval/valid-const.rs @@ -0,0 +1,18 @@ +// compile-pass + +// Some constants that *are* valid +#![feature(const_transmute)] + +use std::mem; +use std::ptr::NonNull; +use std::num::{NonZeroU8, NonZeroUsize}; + +const NON_NULL_PTR1: NonNull = unsafe { mem::transmute(1usize) }; +const NON_NULL_PTR2: NonNull = 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() {}