diff options
| author | bors <bors@rust-lang.org> | 2021-04-12 18:37:31 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-04-12 18:37:31 +0000 |
| commit | e9728b80ce38a1ab94d90d125726d5503e6ab3bb (patch) | |
| tree | d94aeac847ef1aec6993a65094483fd8541b1436 /clippy_lints/src | |
| parent | 2a96bc434b08894584cf569b0d86f4774bf8c47d (diff) | |
| parent | d6beb1841152a80ec10a5039e2294cd074fc3231 (diff) | |
Auto merge of #7068 - boxdot:remove-std-ptr-null, r=camsteffen
Remove paths::STD_PTR_NULL Related to #5393 changelog: none
Diffstat (limited to 'clippy_lints/src')
| -rw-r--r-- | clippy_lints/src/transmuting_null.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/clippy_lints/src/transmuting_null.rs b/clippy_lints/src/transmuting_null.rs index 0be05d3e0cf..755132da591 100644 --- a/clippy_lints/src/transmuting_null.rs +++ b/clippy_lints/src/transmuting_null.rs @@ -1,6 +1,6 @@ use crate::consts::{constant_context, Constant}; use clippy_utils::diagnostics::span_lint; -use clippy_utils::{match_qpath, paths}; +use clippy_utils::{match_def_path, paths}; use if_chain::if_chain; use rustc_ast::LitKind; use rustc_hir::{Expr, ExprKind}; @@ -38,10 +38,10 @@ impl<'tcx> LateLintPass<'tcx> for TransmutingNull { if_chain! { if let ExprKind::Call(func, args) = expr.kind; - if let ExprKind::Path(ref path) = func.kind; - if match_qpath(path, &paths::STD_MEM_TRANSMUTE); if args.len() == 1; - + if let ExprKind::Path(ref path) = func.kind; + if let Some(func_def_id) = cx.qpath_res(path, func.hir_id).opt_def_id(); + if match_def_path(cx, func_def_id, &paths::TRANSMUTE); then { // Catching transmute over constants that resolve to `null`. @@ -69,10 +69,10 @@ impl<'tcx> LateLintPass<'tcx> for TransmutingNull { // Catching: // `std::mem::transmute(std::ptr::null::<i32>())` if_chain! { - if let ExprKind::Call(func1, args1) = args[0].kind; + if let ExprKind::Call(func1, []) = args[0].kind; if let ExprKind::Path(ref path1) = func1.kind; - if match_qpath(path1, &paths::STD_PTR_NULL); - if args1.is_empty(); + if let Some(func1_def_id) = cx.qpath_res(path1, func1.hir_id).opt_def_id(); + if match_def_path(cx, func1_def_id, &paths::PTR_NULL); then { span_lint(cx, TRANSMUTING_NULL, expr.span, LINT_MSG) } |
