-
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
clippy::if_let_some_result suggests changing while to if, resulting in code with different behaviour #7586
Comments
haha @JohnTitor I guess you were right when you said #5032 that
|
I suppose the name of the lint should be changed then? Something like |
@camsteffen Do you think that this is also a regression bug from rust-lang/rust#80357? It looks similar to #7575 that you're fixing in rust-lang/rust#88163 |
Indeed. Let me see if I can throw in a fix for that too. I think we can check for desugaring in |
…=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?
Thanks for fixing. However I was hoping that Clippy would correct while let Some(a) = wat.next().ok() { to while let Ok(a) = wat.next() { but now it seems that it simply does not raise any warnings for this code. Would it be possible to add that, or is that out of the scope of |
I think that could be an enhancement to |
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?
Lint name:
if_let_some_result
I tried this code:
When you run the above code, you get:
I expected to see this happen: while let Ok(a) = wat.next()
Instead, this happened: if let Ok(a) = wat.next()
This is quite dangerous because if you run
--fix
, you will get code with different behaviour!!!Meta
cargo clippy -V
:clippy 0.1.56 (30a0a9b 2021-08-17)
rustc -Vv
:The text was updated successfully, but these errors were encountered: