Skip to content

Commit

Permalink
Only check bindings if the pattern is an or- or never- pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadrieril committed Jan 5, 2024
1 parent be2b0b9 commit ad1bf5d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3324,7 +3324,17 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {

/// 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) {
Expand Down

0 comments on commit ad1bf5d

Please sign in to comment.