Skip to content

Do not expand macro in nonminimal_bool suggestions #9457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clippy_lints/src/booleans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ impl<'a, 'tcx, 'v> SuggestContext<'a, 'tcx, 'v> {
}
},
&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);
},
}
Expand Down
6 changes: 6 additions & 0 deletions tests/ui/nonminimal_bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,9 @@ fn check_expect() {
#[expect(clippy::nonminimal_bool)]
let _ = !!a;
}

fn issue9428() {
if matches!(true, true) && true {
println!("foo");
}
}
8 changes: 7 additions & 1 deletion tests/ui/nonminimal_bool.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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