-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
collapsible_match suggests an incorrect behavior change #7575
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
Comments
dtolnay
added
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
labels
Aug 17, 2021
dtolnay
added a commit
to serde-rs/serde
that referenced
this issue
Aug 17, 2021
dtolnay
added a commit
to dtolnay/syn
that referenced
this issue
Aug 17, 2021
rust-lang/rust-clippy#7575 error: unnecessary nested `if let` or `match` --> src/generics.rs:1190:33 | 1190 | / ... if let TokenTree::Punct(q) = token { 1191 | | ... if q.as_char() == '?' { 1192 | | ... if let Some(TokenTree::Ident(c)) = iter.peek() { 1193 | | ... if c == "const" { ... | 1201 | | ... } 1202 | | ... } | |_______________________^ | = note: `-D clippy::collapsible-match` implied by `-D clippy::all` help: the outer pattern can be modified to include the inner pattern --> src/generics.rs:1189:44 | 1189 | ... while let Some(token) = iter.next() { | ^^^^^ replace this binding 1190 | ... if let TokenTree::Punct(q) = token { | ^^^^^^^^^^^^^^^^^^^ with this pattern = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_match
@rustbot claim |
We had a similar issue with an outer fn next() -> Option<Enum> {
None
}
enum Enum {
Yes,
No,
}
fn main() {
match next() {
Some(thing) => {
if let Enum::Yes = thing {
println!("yes");
}
}
_ => panic!("unexpected None"),
}
} Specifically, the original code does nothing on |
teor2345
added a commit
to ZcashFoundation/zebra
that referenced
this issue
Aug 19, 2021
We don't use the suggestion here, because it's actually wrong. See rust-lang/rust-clippy#7575
1 task
teor2345
added a commit
to ZcashFoundation/zebra
that referenced
this issue
Aug 19, 2021
We don't use the suggestion here, because it's actually wrong. See rust-lang/rust-clippy#7575
conradoplg
pushed a commit
to ZcashFoundation/zebra
that referenced
this issue
Aug 19, 2021
We don't use the suggestion here, because it's actually wrong. See rust-lang/rust-clippy#7575
camsteffen
added a commit
to camsteffen/rust
that referenced
this issue
Aug 19, 2021
…=Manishearth Fix clippy::collapsible_match with let expressions This fixes rust-lang/rust-clippy#7575 which is a regression from rust-lang#80357. I am fixing the bug here instead of in the clippy repo (if that's okay) because a) the regression has not been synced yet and b) I would like to land the fix on nightly asap. The fix is basically to re-generalize `match` and `if let` for the lint implementation (they were split because `if let` no longer desugars to `match` in the HIR). Also fixes rust-lang/rust-clippy#7586 cc `@rust-lang/clippy` `@xFrednet` do you want to review this?
flip1995
pushed a commit
to flip1995/rust-clippy
that referenced
this issue
Aug 26, 2021
Fix clippy::collapsible_match with let expressions This fixes rust-lang#7575 which is a regression from #80357. I am fixing the bug here instead of in the clippy repo (if that's okay) because a) the regression has not been synced yet and b) I would like to land the fix on nightly asap. The fix is basically to re-generalize `match` and `if let` for the lint implementation (they were split because `if let` no longer desugars to `match` in the HIR). Also fixes rust-lang#7586 and fixes rust-lang#7591 cc `@rust-lang/clippy` `@xFrednet` do you want to review this?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
Clippy apparently wants this loop written as:
which is just not the same meaning.
Meta
cargo clippy -V
: e.g. clippy 0.1.56 (0035d9d 2021-08-16)rustc -Vv
:The text was updated successfully, but these errors were encountered: