-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Fix clippy::collapsible_match with let expressions #88163
Conversation
Some changes occurred in src/tools/clippy. cc @rust-lang/clippy |
(rust-highfive has picked a reviewer for you, use r? to override) |
r? @Manishearth |
Sure, I can take a look. 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only a small NIT when it comes to the lint message. I would be okay with merging this and fixing it after the sync if you want this to land ASAP. However, I would prefer to get this fixed before the sync (Also because I'm not sure if we'll have a sync before next week).
I needed some time to get used to the new syntax and structure with the let
expression, and now I like it. Great work!
Another sidenote: The commit is not linked to your GH account (The email probably isn't set). This is not a dealbreaker, just FYI in case that is not intended 🙃
03114cc
to
de608cf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Just one last question
let _ = str_to_int("1"); | ||
let _ = str_to_int_ok("2"); | ||
let _ = strange_some_no_else("3"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rust allows unused
-lints in normal compiler UI tests. Are they now also disabled in Clippy's UI tests? (When running them locally via cargo test
or inside the Clippy CI)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, looks like @rust-log-analyzer answered the question for us ^^. We could add something like that in the future to Clippy as well ^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rust allows
unused
-lints in normal compiler UI tests.
Didn't know that. Sounds good for Clippy.
This comment has been minimized.
This comment has been minimized.
/// must have "wild-like" branches that can be combined. | ||
fn is_wild_like(cx: &LateContext<'_>, pat_kind: &PatKind<'_>, arm_guard: &Option<Guard<'_>>) -> bool { | ||
if arm_guard.is_some() { | ||
enum IfLetOrMatch<'hir> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be in utils IMO, but we can do that refactor once this is synced back
@bors delegate=camsteffen |
✌️ @camsteffen can now approve this pull request |
r=me when tests pass |
de608cf
to
ada9282
Compare
@bors r=Manishearth |
📌 Commit ada9282 has been approved by |
…=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?
☀️ Test successful - checks-actions |
…anishearth 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 and fixes rust-lang/rust-clippy#7591 cc `@rust-lang/clippy` `@xFrednet` do you want to review this?
…earth Add expansion to while desugar spans In the same vein as rust-lang#88163, this reverts a change in Clippy behavior as a result of rust-lang#80357 (and reverts some `#[allow]`s): This changes `clippy::blocks_in_if_conditions` to not fire on `while` loops. Though we might actually want Clippy to lint those cases, we should introduce the change purposefully, with tests, and possibly under a different lint name. The actual change here is to add a desugaring expansion to the spans when lowering a `while` loop. r? `@Manishearth`
…earth Add expansion to while desugar spans In the same vein as rust-lang#88163, this reverts a change in Clippy behavior as a result of rust-lang#80357 (and reverts some `#[allow]`s): This changes `clippy::blocks_in_if_conditions` to not fire on `while` loops. Though we might actually want Clippy to lint those cases, we should introduce the change purposefully, with tests, and possibly under a different lint name. The actual change here is to add a desugaring expansion to the spans when lowering a `while` loop. r? `@Manishearth`
This fixes rust-lang/rust-clippy#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
andif let
for the lint implementation (they were split becauseif let
no longer desugars tomatch
in the HIR).Also fixes rust-lang/rust-clippy#7586 and fixes rust-lang/rust-clippy#7591
cc @rust-lang/clippy
@xFrednet do you want to review this?