about summary refs log tree commit diff
path: root/compiler/rustc_lint/src/builtin.rs
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-07-18 04:27:53 +0200
committerGitHub <noreply@github.com>2025-07-18 04:27:53 +0200
commit19ed2f10be0a5c8175f8e5bb44935ce5f302aa9f (patch)
treea27048a41d82415b08c5c179c95321c94097f3fd /compiler/rustc_lint/src/builtin.rs
parenta7009e93e6fe7bb2f62ee09692293975fb6cdf6d (diff)
parentfad8dec970f51a2d4c23593b059b1684bd85472a (diff)
downloadrust-19ed2f10be0a5c8175f8e5bb44935ce5f302aa9f.tar.gz
rust-19ed2f10be0a5c8175f8e5bb44935ce5f302aa9f.zip
Rollup merge of #144008 - anatawa12:fix-double-negations, r=compiler-errors
Fix false positive double negations with macro invocation

This PR fixes false positive double_negations lint when macro expansion has negation and macro caller also has negations.

Fix rust-lang/rust#143980
Diffstat (limited to 'compiler/rustc_lint/src/builtin.rs')
-rw-r--r--compiler/rustc_lint/src/builtin.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs
index 8244f0bed4c..73e68834232 100644
--- a/compiler/rustc_lint/src/builtin.rs
+++ b/compiler/rustc_lint/src/builtin.rs
@@ -1585,6 +1585,8 @@ impl EarlyLintPass for DoubleNegations {
         if let ExprKind::Unary(UnOp::Neg, ref inner) = expr.kind
             && let ExprKind::Unary(UnOp::Neg, ref inner2) = inner.kind
             && !matches!(inner2.kind, ExprKind::Unary(UnOp::Neg, _))
+            // Don't lint if this jumps macro expansion boundary (Issue #143980)
+            && expr.span.eq_ctxt(inner.span)
         {
             cx.emit_span_lint(
                 DOUBLE_NEGATIONS,