Skip to content

Conversation

@profetia
Copy link
Member

@profetia profetia commented Jan 17, 2026

Closes #16419

changelog: [manual_is_variant_and] enhance to cover manual is_none_or

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jan 17, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 17, 2026

r? @Jarcho

rustbot has assigned @Jarcho.
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

Copy link
Contributor

@Jarcho Jarcho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs an MSRV check. is_none_or is from 1.82 whereas is_some_and is from 1.70. You should also be checking for is_some_and || is_none as well.

View changes since this review

@rustbot rustbot 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 Jan 19, 2026
@profetia
Copy link
Member Author

All resolved. Thank you!

@profetia profetia requested a review from Jarcho January 20, 2026 00:14
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties and removed S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels Jan 20, 2026
Copy link
Contributor

@Jarcho Jarcho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove some redundant work by using something like:

let (none_recv, some_recv, some_arg) = match (&lhs.kind, &rhs.kind) {
  (
    ExprKind::MethodCall(sym::is_none, none_recv, [], ..),
    ExprKind::MethodCall(sym::is_some, some_recv, [some_arg], ..),
  ) => (none_recv, some_recv, some_arg),
  (
    ExprKind::MethodCall(sym::is_some, some_recv, [some_arg], ..),
    ExprKind::MethodCall(sym::is_none, none_recv, [], ..),
  ) => (none_recv, some_recv, some_arg),
  _ => return,
};

You also don't want to use method_call since it doesn't allow any of the arguments to be from an expansion. It really shouldn't ever be used.

View changes since this review

@rustbot rustbot 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 Jan 20, 2026
@profetia profetia force-pushed the issue16419 branch 2 times, most recently from 184ff7c to e4e5741 Compare January 20, 2026 15:14
@profetia profetia requested a review from Jarcho January 22, 2026 21:11
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties and removed S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels Jan 22, 2026
Comment on lines +4981 to +4983
ExprKind::Binary(op, lhs, rhs) if op.node == hir::BinOpKind::Or => {
manual_is_variant_and::check_or(cx, expr, lhs, rhs, self.msrv);
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very awkward imo. Since this particular pattern (opt.is_none() || opt.is_some_and()) doesn't really fit into the methods group, maybe it would make sense to create a separate top-level file to put it into? What do you all think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to keep it here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the lint crate is split either the whole lint will have to be in the methods pass or in a different pass. So this can stay as it is.

@rustbot rustbot 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 Jan 25, 2026
@profetia profetia requested a review from Jarcho January 25, 2026 22:40
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jan 25, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) label Jan 25, 2026
Copy link
Contributor

@Jarcho Jarcho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jarcho Jarcho added this pull request to the merge queue Jan 25, 2026
Merged via the queue into rust-lang:master with commit 1b33602 Jan 25, 2026
11 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jan 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New pattern for manual_is_variant_and

4 participants