Skip to content

Commit ad1bf5d

Browse files
committed
Only check bindings if the pattern is an or- or never- pattern
1 parent be2b0b9 commit ad1bf5d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

compiler/rustc_resolve/src/late.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -3324,7 +3324,17 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
33243324

33253325
/// Check the consistency of bindings wrt or-patterns and never patterns.
33263326
fn check_consistent_bindings(&mut self, pat: &'ast Pat) {
3327-
let _ = self.compute_and_check_binding_map(pat);
3327+
let mut is_or_or_never = false;
3328+
pat.walk(&mut |pat| match pat.kind {
3329+
PatKind::Or(..) | PatKind::Never => {
3330+
is_or_or_never = true;
3331+
false
3332+
}
3333+
_ => true,
3334+
});
3335+
if is_or_or_never {
3336+
let _ = self.compute_and_check_binding_map(pat);
3337+
}
33283338
}
33293339

33303340
fn resolve_arm(&mut self, arm: &'ast Arm) {

0 commit comments

Comments
 (0)