diff options
Diffstat (limited to 'src/test/ui/consts/ptr_is_null.rs')
-rw-r--r-- | src/test/ui/consts/ptr_is_null.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/ui/consts/ptr_is_null.rs b/src/test/ui/consts/ptr_is_null.rs new file mode 100644 index 000000000..8babb6858 --- /dev/null +++ b/src/test/ui/consts/ptr_is_null.rs @@ -0,0 +1,16 @@ +// compile-flags: --crate-type=lib +// check-pass + +#![feature(const_ptr_is_null)] + +const FOO: &usize = &42; + +pub const _: () = assert!(!(FOO as *const usize).is_null()); + +pub const _: () = assert!(!(42 as *const usize).is_null()); + +pub const _: () = assert!((0 as *const usize).is_null()); + +pub const _: () = assert!(std::ptr::null::<usize>().is_null()); + +pub const _: () = assert!(!("foo" as *const str).is_null()); |