rust/tests/ui/consts/const-eval/valid-const.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

19 lines
456 B
Rust
Raw Normal View History

2019-08-30 07:30:59 +00:00
//@ check-pass
2024-02-22 13:59:52 +00:00
//
// Some constants that *are* valid
2024-02-22 13:59:52 +00:00
#![feature(generic_nonzero)]
use std::mem;
use std::ptr::NonNull;
2024-02-22 13:59:52 +00:00
use std::num::NonZero;
const NON_NULL_PTR1: NonNull<u8> = unsafe { mem::transmute(1usize) };
const NON_NULL_PTR2: NonNull<u8> = unsafe { mem::transmute(&0) };
2024-02-22 13:59:52 +00:00
const NON_NULL_U8: NonZero<u8> = unsafe { mem::transmute(1u8) };
const NON_NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(1usize) };
const UNIT: () = ();
fn main() {}