Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd wildcard_match_arm lint #3652
Conversation
phansch
closed this
Jan 11, 2019
phansch
reopened this
Jan 11, 2019
phansch
added
the
S-waiting-on-review
label
Jan 11, 2019
flip1995
requested changes
Jan 11, 2019
|
LGTM! It indeed would be great if you could add tests. You can look in the After you added this file run |
clippy_lints/src/matches.rs Outdated
clippy_lints/src/matches.rs Outdated
flip1995
added
S-waiting-on-author
and removed
S-waiting-on-review
labels
Jan 14, 2019
This comment has been minimized.
This comment has been minimized.
|
Update: I've made some changes (including the above), but it'll be a few days until I can finish implementing the tests. I'll push everything once that's done. |
Aehmlo
force-pushed the
Aehmlo:where_the_wild_things_are
branch
from
d1aa886
to
a41ecc4
Jan 25, 2019
Aehmlo
closed this
Jan 25, 2019
Aehmlo
reopened this
Jan 25, 2019
This comment has been minimized.
This comment has been minimized.
|
Wrong button! I think this should be good to go now. |
Aehmlo
changed the title
Add match_wild lint.
Add wildcard_match_arm lint
Jan 25, 2019
flip1995
approved these changes
Jan 26, 2019
This comment has been minimized.
This comment has been minimized.
|
Thanks! Only a |
This comment has been minimized.
This comment has been minimized.
|
Ran |
This comment has been minimized.
This comment has been minimized.
|
Thanks! That should be fixed by now. @bors r+ |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
added a commit
that referenced
this pull request
Jan 29, 2019
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
It seems that a formatting of the tests is missing. This should be the last chore. https://travis-ci.com/rust-lang/rust-clippy/jobs/173709864#L1383-L1447 A |
Aehmlo
force-pushed the
Aehmlo:where_the_wild_things_are
branch
from
7056388
to
f56e013
Jan 29, 2019
This comment has been minimized.
This comment has been minimized.
|
Neither |
This comment has been minimized.
This comment has been minimized.
|
@bors retry |
This comment has been minimized.
This comment has been minimized.
|
I think it would be better just to emit a lint in cases of an enum. So match 3 {
4 => println!(),
_ => println!(),
};would not emit a warning. Note also that it would need to check for matching in an enum on any nesting level. I.e. match Some(Color::Red) {
Some(Color::Blue) => println!(),
Some(_) => println!(),
None => println!(),
};would emit a lint. |
This comment has been minimized.
This comment has been minimized.
|
@bors r- pending decision on linting non-enum matches |
This comment has been minimized.
This comment has been minimized.
|
I agree re: linting only on enums. I've changed the behavior and updated the lint name accordingly. I'm not familiar enough with compiler internals to implement the nested check yet, so I added a note of this limitation to the known issues. I may try to resolve this in the future if I have time, or someone else can, but I won't be able to do it in the near future. Thanks for the insightful feedback, @orium! |
This comment has been minimized.
This comment has been minimized.
|
@bors r+ LGTM now, thanks! |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
added a commit
that referenced
this pull request
Jan 29, 2019
Aehmlo
added some commits
Jan 10, 2019
Aehmlo
force-pushed the
Aehmlo:where_the_wild_things_are
branch
from
97c7d28
to
7fa50fb
Jan 29, 2019
This comment has been minimized.
This comment has been minimized.
|
Updated lint count; should actually work next time. |
This comment has been minimized.
This comment has been minimized.
|
@bors retry |
This comment has been minimized.
This comment has been minimized.
|
@bors ping |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@bors r=phansch |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
added a commit
that referenced
this pull request
Jan 29, 2019
This comment has been minimized.
This comment has been minimized.
|
|
Aehmlo commentedJan 10, 2019
This lint prevents using a wildcard in a match arm. Implemented as a restriction currently, because this is pretty much an edge case. See #3649 for more information.
Didn't add any tests because I wasn't sure how, but if someone wants to point me in the right direction, I'd be happy to!