Only check bindings if the pattern is an or- or never- pattern
This commit is contained in:
parent
560beb1ad4
commit
807d618676
@ -3324,8 +3324,18 @@ fn compute_and_check_or_pat_binding_map(
|
|||||||
|
|
||||||
/// Check the consistency of bindings wrt or-patterns and never patterns.
|
/// Check the consistency of bindings wrt or-patterns and never patterns.
|
||||||
fn check_consistent_bindings(&mut self, pat: &'ast Pat) {
|
fn check_consistent_bindings(&mut self, pat: &'ast 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);
|
let _ = self.compute_and_check_binding_map(pat);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn resolve_arm(&mut self, arm: &'ast Arm) {
|
fn resolve_arm(&mut self, arm: &'ast Arm) {
|
||||||
self.with_rib(ValueNS, RibKind::Normal, |this| {
|
self.with_rib(ValueNS, RibKind::Normal, |this| {
|
||||||
|
Loading…
Reference in New Issue
Block a user