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

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

9 lines
212 B
Rust
Raw Normal View History

2022-09-23 10:52:53 -05:00
//@ check-pass
use std::ptr::NonNull;
const NON_NULL: NonNull<u8> = unsafe { NonNull::new_unchecked((&42u8 as *const u8).cast_mut()) };
const _: () = assert!(42 == *unsafe { NON_NULL.as_ref() });
fn main() {}