Don't trigger if a binding is in the else pattern

This commit is contained in:
Micha White 2022-06-09 20:01:22 -04:00
parent 2967127de2
commit b46f1c4a7f
No known key found for this signature in database
GPG key ID: AED94BFA1C301389

View file

@ -242,7 +242,10 @@ fn form_exhaustive_matches<'a>(cx: &LateContext<'a>, ty: Ty<'a>, left: &Pat<'_>,
}
true
},
(PatKind::TupleStruct(..), PatKind::Path(_) | PatKind::TupleStruct(..)) => in_candidate_enum(cx, ty),
(PatKind::TupleStruct(..), PatKind::Path(_)) => in_candidate_enum(cx, ty),
(PatKind::TupleStruct(..), PatKind::TupleStruct(_, inner, _)) => {
in_candidate_enum(cx, ty) && inner.iter().all(contains_only_wilds)
},
_ => false,
}
}