diff options
| author | Philipp Krones <hello@philkrones.com> | 2025-05-15 19:19:08 +0200 |
|---|---|---|
| committer | Philipp Krones <hello@philkrones.com> | 2025-05-15 19:19:08 +0200 |
| commit | 0bb1b5bd3b7eecd248ae709fb43826bd6f89a4ab (patch) | |
| tree | 8830102e10a6d1b6831fd6996320d28d3543778c /clippy_lints/src/mutable_debug_assertion.rs | |
| parent | 303c4ecfdd0c571d80c5bc151243aee1900cebfd (diff) | |
| parent | 40bead02a528980645dda94a63b16526f9d2ffc3 (diff) | |
| download | rust-0bb1b5bd3b7eecd248ae709fb43826bd6f89a4ab.tar.gz rust-0bb1b5bd3b7eecd248ae709fb43826bd6f89a4ab.zip | |
Merge remote-tracking branch 'upstream/master' into rustup
Diffstat (limited to 'clippy_lints/src/mutable_debug_assertion.rs')
| -rw-r--r-- | clippy_lints/src/mutable_debug_assertion.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/clippy_lints/src/mutable_debug_assertion.rs b/clippy_lints/src/mutable_debug_assertion.rs index 270eebe0758..9b327955608 100644 --- a/clippy_lints/src/mutable_debug_assertion.rs +++ b/clippy_lints/src/mutable_debug_assertion.rs @@ -1,5 +1,6 @@ use clippy_utils::diagnostics::span_lint; use clippy_utils::macros::{find_assert_eq_args, root_macro_call_first_node}; +use clippy_utils::sym; use rustc_hir::intravisit::{Visitor, walk_expr}; use rustc_hir::{BorrowKind, Expr, ExprKind, MatchSource, Mutability}; use rustc_lint::{LateContext, LateLintPass}; @@ -42,10 +43,9 @@ impl<'tcx> LateLintPass<'tcx> for DebugAssertWithMutCall { let Some(macro_call) = root_macro_call_first_node(cx, e) else { return; }; - let macro_name = cx.tcx.item_name(macro_call.def_id); if !matches!( - macro_name.as_str(), - "debug_assert" | "debug_assert_eq" | "debug_assert_ne" + cx.tcx.get_diagnostic_name(macro_call.def_id), + Some(sym::debug_assert_macro | sym::debug_assert_eq_macro | sym::debug_assert_ne_macro) ) { return; } @@ -60,7 +60,10 @@ impl<'tcx> LateLintPass<'tcx> for DebugAssertWithMutCall { cx, DEBUG_ASSERT_WITH_MUT_CALL, span, - format!("do not call a function with mutable arguments inside of `{macro_name}!`"), + format!( + "do not call a function with mutable arguments inside of `{}!`", + cx.tcx.item_name(macro_call.def_id) + ), ); } } @@ -96,10 +99,6 @@ impl<'tcx> Visitor<'tcx> for MutArgVisitor<'_, 'tcx> { self.found = true; return; }, - ExprKind::If(..) => { - self.found = true; - return; - }, ExprKind::Path(_) => { if let Some(adj) = self.cx.typeck_results().adjustments().get(expr.hir_id) && adj |
