mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 10:45:18 +00:00
19 lines
456 B
Rust
19 lines
456 B
Rust
//@ check-pass
|
|
//
|
|
// Some constants that *are* valid
|
|
#![feature(generic_nonzero)]
|
|
|
|
use std::mem;
|
|
use std::ptr::NonNull;
|
|
use std::num::NonZero;
|
|
|
|
const NON_NULL_PTR1: NonNull<u8> = unsafe { mem::transmute(1usize) };
|
|
const NON_NULL_PTR2: NonNull<u8> = unsafe { mem::transmute(&0) };
|
|
|
|
const NON_NULL_U8: NonZero<u8> = unsafe { mem::transmute(1u8) };
|
|
const NON_NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(1usize) };
|
|
|
|
const UNIT: () = ();
|
|
|
|
fn main() {}
|