Auto merge of #80367 - camelid:check_match-combine-loop, r=Nadrieril
Combine two loops in `check_match` Suggested by Nadrieril in https://github.com/rust-lang/rust/pull/79051#discussion_r548778186. Opening to get a perf run. Hopefully this code doesn't require everything in the first loop to be done before running the second! (It shouldn't though.) cc `@Nadrieril`
This commit is contained in:
commit
2faabf5793
1 changed files with 3 additions and 8 deletions
|
@ -112,7 +112,7 @@ impl PatCtxt<'_, '_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> MatchVisitor<'_, 'tcx> {
|
impl<'tcx> MatchVisitor<'_, 'tcx> {
|
||||||
fn check_patterns(&mut self, pat: &Pat<'_>) {
|
fn check_patterns(&self, pat: &Pat<'_>) {
|
||||||
pat.walk_always(|pat| check_borrow_conflicts_in_at_patterns(self, pat));
|
pat.walk_always(|pat| check_borrow_conflicts_in_at_patterns(self, pat));
|
||||||
check_for_bindings_named_same_as_variants(self, pat);
|
check_for_bindings_named_same_as_variants(self, pat);
|
||||||
}
|
}
|
||||||
|
@ -150,18 +150,13 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
|
||||||
arms: &'tcx [hir::Arm<'tcx>],
|
arms: &'tcx [hir::Arm<'tcx>],
|
||||||
source: hir::MatchSource,
|
source: hir::MatchSource,
|
||||||
) {
|
) {
|
||||||
|
let mut cx = self.new_cx(scrut.hir_id);
|
||||||
|
|
||||||
for arm in arms {
|
for arm in arms {
|
||||||
// Check the arm for some things unrelated to exhaustiveness.
|
// Check the arm for some things unrelated to exhaustiveness.
|
||||||
self.check_patterns(&arm.pat);
|
self.check_patterns(&arm.pat);
|
||||||
if let Some(hir::Guard::IfLet(ref pat, _)) = arm.guard {
|
if let Some(hir::Guard::IfLet(ref pat, _)) = arm.guard {
|
||||||
self.check_patterns(pat);
|
self.check_patterns(pat);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut cx = self.new_cx(scrut.hir_id);
|
|
||||||
|
|
||||||
for arm in arms {
|
|
||||||
if let Some(hir::Guard::IfLet(ref pat, _)) = arm.guard {
|
|
||||||
let tpat = self.lower_pattern(&mut cx, pat, &mut false).0;
|
let tpat = self.lower_pattern(&mut cx, pat, &mut false).0;
|
||||||
check_if_let_guard(&mut cx, &tpat, pat.hir_id);
|
check_if_let_guard(&mut cx, &tpat, pat.hir_id);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue