Do not expand macro in nonminimal_bool suggestions

This commit is contained in:
kraktus 2022-09-10 19:48:14 +02:00
parent da8afc9ecf
commit d50f366612
3 changed files with 14 additions and 2 deletions

View file

@ -237,7 +237,7 @@ impl<'a, 'tcx, 'v> SuggestContext<'a, 'tcx, 'v> {
} }
}, },
&Term(n) => { &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); self.output.push_str(&snip);
}, },
} }

View file

@ -57,3 +57,9 @@ fn check_expect() {
#[expect(clippy::nonminimal_bool)] #[expect(clippy::nonminimal_bool)]
let _ = !!a; let _ = !!a;
} }
fn issue9428() {
if matches!(true, true) && true {
println!("foo");
}
}

View file

@ -107,5 +107,11 @@ LL | let _ = !(a == b || c == d);
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