2019-02-28 00:32:13 -06:00
|
|
|
use std::ptr::NonNull;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let x: &'static NonNull<u32> = &(NonNull::dangling());
|
2019-04-22 02:40:08 -05:00
|
|
|
//~^ ERROR temporary value dropped while borrowed
|
2019-02-28 00:32:13 -06:00
|
|
|
|
|
|
|
let mut i: i32 = 10;
|
|
|
|
let non_null = NonNull::new(&mut i).unwrap();
|
|
|
|
let x: &'static NonNull<u32> = &(non_null.cast());
|
2019-04-22 02:40:08 -05:00
|
|
|
//~^ ERROR temporary value dropped while borrowed
|
2019-02-28 00:32:13 -06:00
|
|
|
}
|