|
1 |
| -use std::marker::PhantomData; |
2 |
| - |
3 | 1 | use crate::build::expr::as_place::{PlaceBase, PlaceBuilder};
|
4 | 2 | use crate::build::matches::{Binding, Candidate, FlatPat, MatchPair, TestCase};
|
5 | 3 | use crate::build::Builder;
|
@@ -458,57 +456,6 @@ impl<'a, 'b, 'tcx> FakeBorrowCollector<'a, 'b, 'tcx> {
|
458 | 456 | }
|
459 | 457 | }
|
460 | 458 |
|
461 |
| -/// Visit all the bindings of these candidates. Because or-alternatives bind the same variables, we |
462 |
| -/// only explore the first one of each or-pattern. |
463 |
| -pub(super) fn visit_bindings<'tcx>( |
464 |
| - candidates: &[&mut Candidate<'_, 'tcx>], |
465 |
| - f: impl FnMut(&Binding<'tcx>), |
466 |
| -) { |
467 |
| - let mut visitor = BindingsVisitor { f, phantom: PhantomData }; |
468 |
| - for candidate in candidates.iter() { |
469 |
| - visitor.visit_candidate(candidate); |
470 |
| - } |
471 |
| -} |
472 |
| - |
473 |
| -pub(super) struct BindingsVisitor<'tcx, F> { |
474 |
| - f: F, |
475 |
| - phantom: PhantomData<&'tcx ()>, |
476 |
| -} |
477 |
| - |
478 |
| -impl<'tcx, F> BindingsVisitor<'tcx, F> |
479 |
| -where |
480 |
| - F: FnMut(&Binding<'tcx>), |
481 |
| -{ |
482 |
| - fn visit_candidate(&mut self, candidate: &Candidate<'_, 'tcx>) { |
483 |
| - for binding in &candidate.extra_data.bindings { |
484 |
| - (self.f)(binding) |
485 |
| - } |
486 |
| - for match_pair in &candidate.match_pairs { |
487 |
| - self.visit_match_pair(match_pair); |
488 |
| - } |
489 |
| - } |
490 |
| - |
491 |
| - fn visit_flat_pat(&mut self, flat_pat: &FlatPat<'_, 'tcx>) { |
492 |
| - for binding in &flat_pat.extra_data.bindings { |
493 |
| - (self.f)(binding) |
494 |
| - } |
495 |
| - for match_pair in &flat_pat.match_pairs { |
496 |
| - self.visit_match_pair(match_pair); |
497 |
| - } |
498 |
| - } |
499 |
| - |
500 |
| - fn visit_match_pair(&mut self, match_pair: &MatchPair<'_, 'tcx>) { |
501 |
| - if let TestCase::Or { pats, .. } = &match_pair.test_case { |
502 |
| - // All the or-alternatives should bind the same locals, so we only visit the first one. |
503 |
| - self.visit_flat_pat(&pats[0]) |
504 |
| - } else { |
505 |
| - for subpair in &match_pair.subpairs { |
506 |
| - self.visit_match_pair(subpair); |
507 |
| - } |
508 |
| - } |
509 |
| - } |
510 |
| -} |
511 |
| - |
512 | 459 | #[must_use]
|
513 | 460 | pub(crate) fn ref_pat_borrow_kind(ref_mutability: Mutability) -> BorrowKind {
|
514 | 461 | match ref_mutability {
|
|
0 commit comments