diff options
Diffstat (limited to 'tests/ui/consts/const-ptr-nonnull.rs')
-rw-r--r-- | tests/ui/consts/const-ptr-nonnull.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/ui/consts/const-ptr-nonnull.rs b/tests/ui/consts/const-ptr-nonnull.rs new file mode 100644 index 000000000..25cf6cf4a --- /dev/null +++ b/tests/ui/consts/const-ptr-nonnull.rs @@ -0,0 +1,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 +} |