summaryrefslogtreecommitdiffstats
path: root/tests/ui/consts/ptr_is_null.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/consts/ptr_is_null.rs')
-rw-r--r--tests/ui/consts/ptr_is_null.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/ui/consts/ptr_is_null.rs b/tests/ui/consts/ptr_is_null.rs
new file mode 100644
index 000000000..8babb6858
--- /dev/null
+++ b/tests/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());