We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7826d97 commit 0436a82Copy full SHA for 0436a82
src/test/ui/consts/const-eval/valid-const.rs
@@ -0,0 +1,18 @@
1
+// compile-pass
2
+
3
+// Some constants that *are* valid
4
+#![feature(const_transmute)]
5
6
+use std::mem;
7
+use std::ptr::NonNull;
8
+use std::num::{NonZeroU8, NonZeroUsize};
9
10
+const NON_NULL_PTR1: NonNull<u8> = unsafe { mem::transmute(1usize) };
11
+const NON_NULL_PTR2: NonNull<u8> = unsafe { mem::transmute(&0) };
12
13
+const NON_NULL_U8: NonZeroU8 = unsafe { mem::transmute(1u8) };
14
+const NON_NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(1usize) };
15
16
+const UNIT: () = ();
17
18
+fn main() {}
0 commit comments