Only check bindings if the pattern is an or- or never- pattern

This commit is contained in:
Nadrieril 2024-01-09 17:05:55 +01:00
parent 560beb1ad4
commit 807d618676

View File

@ -3324,7 +3324,17 @@ fn compute_and_check_or_pat_binding_map(
/// Check the consistency of bindings wrt or-patterns and never patterns.
fn check_consistent_bindings(&mut self, pat: &'ast Pat) {
let _ = self.compute_and_check_binding_map(pat);
let mut is_or_or_never = false;
pat.walk(&mut |pat| match pat.kind {
PatKind::Or(..) | PatKind::Never => {
is_or_or_never = true;
false
}
_ => true,
});
if is_or_or_never {
let _ = self.compute_and_check_binding_map(pat);
}
}
fn resolve_arm(&mut self, arm: &'ast Arm) {