Skip to content

Commit d50f366

Browse files
committed
Do not expand macro in nonminimal_bool suggestions
1 parent da8afc9 commit d50f366

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

clippy_lints/src/booleans.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ impl<'a, 'tcx, 'v> SuggestContext<'a, 'tcx, 'v> {
237237
}
238238
},
239239
&Term(n) => {
240-
let snip = snippet_opt(self.cx, self.terminals[n as usize].span)?;
240+
let snip = snippet_opt(self.cx, self.terminals[n as usize].span.source_callsite())?;
241241
self.output.push_str(&snip);
242242
},
243243
}

tests/ui/nonminimal_bool.rs

+6
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,9 @@ fn check_expect() {
5757
#[expect(clippy::nonminimal_bool)]
5858
let _ = !!a;
5959
}
60+
61+
fn issue9428() {
62+
if matches!(true, true) && true {
63+
println!("foo");
64+
}
65+
}

tests/ui/nonminimal_bool.stderr

+7-1
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,11 @@ LL | let _ = !(a == b || c == d);
107107
LL | let _ = a != b && c != d;
108108
| ~~~~~~~~~~~~~~~~
109109

110-
error: aborting due to 12 previous errors
110+
error: this boolean expression can be simplified
111+
--> $DIR/nonminimal_bool.rs:62:8
112+
|
113+
LL | if matches!(true, true) && true {
114+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(true, true)`
115+
116+
error: aborting due to 13 previous errors
111117

0 commit comments

Comments
 (0)