Make manual_is_variant_and to cover manual is_none_or#16424
Make manual_is_variant_and to cover manual is_none_or#16424Jarcho merged 1 commit intorust-lang:masterfrom
manual_is_variant_and to cover manual is_none_or#16424Conversation
|
All resolved. Thank you! |
There was a problem hiding this comment.
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.
184ff7c to
e4e5741
Compare
| ExprKind::Binary(op, lhs, rhs) if op.node == hir::BinOpKind::Or => { | ||
| manual_is_variant_and::check_or(cx, expr, lhs, rhs, self.msrv); | ||
| }, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
I prefer to keep it here.
There was a problem hiding this comment.
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.
Closes #16419
changelog: [
manual_is_variant_and] enhance to cover manualis_none_or