]> git.lizzy.rs Git - rust.git/commitdiff
Do not expand macro in `nonminimal_bool` suggestions
authorkraktus <kraktus@users.noreply.github.com>
Sat, 10 Sep 2022 17:48:14 +0000 (19:48 +0200)
committerkraktus <kraktus@users.noreply.github.com>
Sat, 10 Sep 2022 17:48:14 +0000 (19:48 +0200)
clippy_lints/src/booleans.rs
tests/ui/nonminimal_bool.rs
tests/ui/nonminimal_bool.stderr

index 656d639f0efd9838c272c92d6aa0e5d2e3fa7179..03d262d5a59c64e2afbd25af634984080c9721b8 100644 (file)
@@ -237,7 +237,7 @@ fn recurse(&mut self, suggestion: &Bool) -> Option<()> {
                 }
             },
             &Term(n) => {
-                let snip = snippet_opt(self.cx, self.terminals[n as usize].span)?;
+                let snip = snippet_opt(self.cx, self.terminals[n as usize].span.source_callsite())?;
                 self.output.push_str(&snip);
             },
         }
index 24ae62bb05884104c59d25e7d20ed0260a35481d..e9b4367ca653cd5dcb95dd59108c76c26d37c87c 100644 (file)
@@ -57,3 +57,9 @@ fn check_expect() {
     #[expect(clippy::nonminimal_bool)]
     let _ = !!a;
 }
+
+fn issue9428() {
+    if matches!(true, true) && true {
+        println!("foo");
+    }
+}
index fc6a5ce1dc2eef4e6ffc2860aa19154b84c53614..91b5805aa97ab8f6b4c243c81bc840b1a4b3bb22 100644 (file)
@@ -107,5 +107,11 @@ LL |     let _ = !(a == b || c == d);
 LL |     let _ = a != b && c != d;
    |             ~~~~~~~~~~~~~~~~
 
-error: aborting due to 12 previous errors
+error: this boolean expression can be simplified
+  --> $DIR/nonminimal_bool.rs:62:8
+   |
+LL |     if matches!(true, true) && true {
+   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(true, true)`
+
+error: aborting due to 13 previous errors