Skip to content

Commit 8dcc446

Browse files
committed
Check also for std::ptr::{null, null_mut}.
1 parent 446acc7 commit 8dcc446

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
@@ -356,7 +356,10 @@ fn is_null_path(expr: &Expr<'_>) -> bool {
356356
if let ExprKind::Call(ref pathexp, ref args) = expr.kind {
357357
if args.is_empty() {
358358
if let ExprKind::Path(ref path) = pathexp.kind {
359-
return match_qpath(path, &paths::PTR_NULL) || match_qpath(path, &paths::PTR_NULL_MUT);
359+
return match_qpath(path, &paths::PTR_NULL)
360+
|| match_qpath(path, &paths::PTR_NULL_MUT)
361+
|| match_qpath(path, &paths::STD_PTR_NULL)
362+
|| match_qpath(path, &paths::STD_PTR_NULL_MUT);
360363
}
361364
}
362365
}

clippy_lints/src/utils/paths.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ pub const STD_CONVERT_IDENTITY: [&str; 3] = ["std", "convert", "identity"];
125125
pub const STD_FS_CREATE_DIR: [&str; 3] = ["std", "fs", "create_dir"];
126126
pub const STD_MEM_TRANSMUTE: [&str; 3] = ["std", "mem", "transmute"];
127127
pub const STD_PTR_NULL: [&str; 3] = ["std", "ptr", "null"];
128+
pub const STD_PTR_NULL_MUT: [&str; 3] = ["std", "ptr", "null_mut"];
128129
pub const STRING: [&str; 3] = ["alloc", "string", "String"];
129130
pub const STRING_AS_MUT_STR: [&str; 4] = ["alloc", "string", "String", "as_mut_str"];
130131
pub const STRING_AS_STR: [&str; 4] = ["alloc", "string", "String", "as_str"];

0 commit comments

Comments
 (0)