Skip to content

Commit 07ed908

Browse files
committed
Check also for std::ptr::{null, null_mut}.
1 parent 6f7be88 commit 07ed908

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

clippy_lints/src/ptr.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,10 @@ fn is_null_path(expr: &Expr<'_>) -> bool {
384384
if let ExprKind::Call(ref pathexp, ref args) = expr.kind {
385385
if args.is_empty() {
386386
if let ExprKind::Path(ref path) = pathexp.kind {
387-
return match_qpath(path, &paths::PTR_NULL) || match_qpath(path, &paths::PTR_NULL_MUT);
387+
return match_qpath(path, &paths::PTR_NULL)
388+
|| match_qpath(path, &paths::PTR_NULL_MUT)
389+
|| match_qpath(path, &paths::STD_PTR_NULL)
390+
|| match_qpath(path, &paths::STD_PTR_NULL_MUT);
388391
}
389392
}
390393
}

clippy_utils/src/paths.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ pub const STD_CONVERT_IDENTITY: [&str; 3] = ["std", "convert", "identity"];
136136
pub const STD_FS_CREATE_DIR: [&str; 3] = ["std", "fs", "create_dir"];
137137
pub const STD_MEM_TRANSMUTE: [&str; 3] = ["std", "mem", "transmute"];
138138
pub const STD_PTR_NULL: [&str; 3] = ["std", "ptr", "null"];
139+
pub const STD_PTR_NULL_MUT: [&str; 3] = ["std", "ptr", "null_mut"];
139140
pub const STRING_AS_MUT_STR: [&str; 4] = ["alloc", "string", "String", "as_mut_str"];
140141
pub const STRING_AS_STR: [&str; 4] = ["alloc", "string", "String", "as_str"];
141142
pub const STR_ENDS_WITH: [&str; 4] = ["core", "str", "<impl str>", "ends_with"];

0 commit comments

Comments
 (0)