]> git.lizzy.rs Git - rust.git/blob - tests/ui/consts/const-ptr-nonnull-rpass.rs
Rollup merge of #106717 - klensy:typo, r=lcnr
[rust.git] / tests / ui / consts / const-ptr-nonnull-rpass.rs
1 // run-pass
2
3 #![feature(ptr_internals, test)]
4
5 extern crate test;
6 use test::black_box as b; // prevent promotion of the argument and const-propagation of the result
7
8 use std::ptr::NonNull;
9
10 const DANGLING: NonNull<u32> = NonNull::dangling();
11 const CASTED: NonNull<u32> = NonNull::cast(NonNull::<i32>::dangling());
12
13 pub fn main() {
14     // Be super-extra paranoid and cast the fn items to fn pointers before blackboxing them.
15     assert_eq!(DANGLING, b::<fn() -> _>(NonNull::dangling)());
16     assert_eq!(CASTED, b::<fn() -> _>(NonNull::dangling)());
17 }