os-rust/tests/ui/consts/ptr_is_null.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

17 lines
422 B
Rust
Raw Normal View History

2020-07-30 12:27:34 +02:00
//@ compile-flags: --crate-type=lib
//@ check-pass
#![allow(useless_ptr_null_checks)]
2020-07-30 12:27:34 +02:00
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());