RS.CLIPPY.CMP_NULL
Comparing a pointer to a null pointer, suggesting to use `.is_null()` instead
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: cmp_null. Copyright ©2025 The Rust Team. All rights reserved.
What it does
This lint checks for equality comparisons with ptr::null
Why is this bad?
It's easier and more readable to use the inherent
.is_null()
method instead
Example
use std::ptr;
if x == ptr::null {
// ..
}
Use instead:
if x.is_null() {
// ..
}