Skip to content

Commit

Permalink
add some tests with constants that better be valid
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Oct 3, 2018
1 parent 7826d97 commit 0436a82
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/test/ui/consts/const-eval/valid-const.rs
Original file line number Diff line number Diff line change
@@ -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() {}

0 comments on commit 0436a82

Please sign in to comment.