rust/tests/ui/cmp_null.rs
2019-01-08 21:46:39 +01:00

17 lines
334 B
Rust

#![warn(clippy::cmp_null)]
#![allow(unused_mut)]
use std::ptr;
fn main() {
let x = 0;
let p: *const usize = &x;
if p == ptr::null() {
println!("This is surprising!");
}
let mut y = 0;
let mut m: *mut usize = &mut y;
if m == ptr::null_mut() {
println!("This is surprising, too!");
}
}