rust/tests/ui/consts/const-ptr-nonnull.rs
2023-01-11 09:32:08 +00:00

12 lines
336 B
Rust

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
}