Skip to content

Conversation

zihan0822
Copy link
Contributor

@zihan0822 zihan0822 commented Aug 26, 2025

Fixes #15559

changelog: [unit_cmp]: don't lint on explicitly written unit expr

changelog: [`unit_cmp`]: don't lint on explicitly written unit expr

Signed-off-by: Zihan <zihanli0822@gmail.com>
@rustbot
Copy link
Collaborator

rustbot commented Aug 26, 2025

r? @blyxyas

rustbot has assigned @blyxyas.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Aug 26, 2025
Copy link
Member

@samueltardieu samueltardieu left a 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() {}
Copy link
Member

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()).

Comment on lines +22 to +25
if !cx.typeck_results().expr_ty(lhs).is_unit() {
return;
}
if is_unit_expr(lhs) || is_unit_expr(rhs) {
Copy link
Member

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.

@rustbot rustbot assigned samueltardieu and unassigned blyxyas Aug 26, 2025
@samueltardieu samueltardieu added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Aug 26, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 26, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unit_cmp: don't lint on explicitly written units
4 participants