-
Notifications
You must be signed in to change notification settings - Fork 1.7k
match_same_arms
, ifs_same_cond
: lint once per same arm/condition
#14637
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
Conversation
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.
Really nice improvement.
clippy_utils/src/lib.rs
Outdated
/// `exprs` | ||
/// Returns a list of groups where elements in each group are equal according to `eq` | ||
/// | ||
/// Groups contain at least two elements and appear in the order they occur in `exprs` |
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.
/// Groups contain at least two elements and appear in the order they occur in `exprs` | |
/// Groups contain at least two elements which appear in the order they occur in `exprs` |
The groups themselves are not ordered, only elements within a group are.
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.
The groups are also ordered, updated the comment to say that
group.iter().map(|(_, arm)| arm.span).collect_vec(), | ||
"these match arms have identical bodies", | ||
|diag| { | ||
diag.help("make the arms return different values"); |
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.
I find this suggestion a bit strange. While it sounds logical to group the arms if possible, changing the body value means changing the semantics.
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.
It's from the basis that the same arms may not be intentional and so inherently require changing the semantics, reworded it to state that explicitly
@Alexendoo This looks really nice (see the two nitpicking comments). I like how the patterns stay in order compared to the previous implementation. I prefer to wait until 1.88 is branched out of master (in two days) before merging this in case an unplanned Clippy sync happens in the meantime. Given the scope of the change, a full nightly + beta cycle will be useful to catch any oversight. |
@rustbot author |
d6ccb71
to
39ab00a
Compare
Thanks! |
A large fraction of the lints emitted in CI lintcheck come from this
match
, currently forn
same arms((n - 1) * n)/2
lints are emitted, with this change it will be emitted as a single lintAlso fixes #13835
changelog: none