summaryrefslogtreecommitdiffstats
path: root/tests/ui/consts/const-ptr-nonnull.rs
blob: 25cf6cf4aaa6c76f43bd250254ffce88929d3089 (plain)
1
2
3
4
5
6
7
8
9
10
11
use std::ptr::NonNull;

fn main() {
    let x: &'static NonNull<u32> = &(NonNull::dangling());
    //~^ ERROR temporary value dropped while borrowed

    let mut i: i32 = 10;
    let non_null = NonNull::new(&mut i).unwrap();
    let x: &'static NonNull<u32> = &(non_null.cast());
    //~^ ERROR temporary value dropped while borrowed
}