-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
False positive in if_same_then_else
lint
#7383
Comments
I get the same false positive for another smaller repro (only since
|
Duplicate of #3770. TL;DR: This is working as intended, as two adjacent branches are the same. The fact that both branches are so simple makes it seem like an FP. We thought about allowing such "simple" cases, but it would be hard to determine if a statement/expression is actually simple or not. For now, I would recommend allowing the lint for that specific block and maybe also #[allow(clippy::if_same_then_else, clippy::branches_sharing_code)] |
@xFrednet but how is one supposed to combine both into one |
Ahh, in your case, it's actually an if-let and if block. I missed that, as that is not part of the main issue description. Thank you for the clarification. Currently, this is not possible, but should soon be with RFC 2497 that allows if let chains. |
Ok but that means that until if-let chaining works this is a false-positive warning, right? Should I make a new issue with a more specific description to my case? |
Correct! And it might take some time until that feature gets stabilized.
It would be awesome if you could do that @extrawurst. Could you also ping me in it? Then I would close this issue in favor of #3770 and the newly created issue 🙃. |
Lint name:
if_same_then_else
I tried this code:
(this is a minimal example adapted from real code; real code can be found here)
I expected to see this happen: no warnings
Instead, this happened:
Meta
cargo clippy -V
: both0.1.54 (2021-06-19 150fad3)
andclippy 0.1.52 (9bc8c42 2021-05-09)
rustc -Vv
:The text was updated successfully, but these errors were encountered: