Skip to content

Commit 0436a82

Browse files
committed
add some tests with constants that better be valid
1 parent 7826d97 commit 0436a82

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)