mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-02 11:44:28 +00:00
add some tests with constants that better be valid
This commit is contained in:
parent
22c1a0acc8
commit
95593331bf
18
src/test/ui/consts/const-eval/valid-const.rs
Normal file
18
src/test/ui/consts/const-eval/valid-const.rs
Normal file
@ -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<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() {}
|
Loading…
Reference in New Issue
Block a user