-
Notifications
You must be signed in to change notification settings - Fork 1.8k
unit_cmp
: don't lint on explicitly written unit expr
#15562
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
base: master
Are you sure you want to change the base?
Conversation
changelog: [`unit_cmp`]: don't lint on explicitly written unit expr Signed-off-by: Zihan <zihanli0822@gmail.com>
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.
Some small comments, otherwise it looks fine!
r? samueltardieu
@rustbot author
@@ -68,3 +68,17 @@ fn main() { | |||
} | |||
); | |||
} | |||
|
|||
fn issue15559() { | |||
fn foo() {} |
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.
Since we're at it, please add a test for assert_eq!(foo(), foo())
.
if !cx.typeck_results().expr_ty(lhs).is_unit() { | ||
return; | ||
} | ||
if is_unit_expr(lhs) || is_unit_expr(rhs) { |
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.
Please switch those tests, is_unit_expr()
is cheaper than expr_ty()
, so is_unit_expr()
should go first.
Reminder, once the PR becomes ready for a review, use |
Fixes #15559
changelog: [
unit_cmp
]: don't lint on explicitly written unit expr