mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 06:51:58 +00:00
12 lines
336 B
Rust
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
|
|
}
|