|
1 |
| -use std::marker::PhantomData; |
2 |
| - |
3 | 1 | use crate::build::expr::as_place::PlaceBase;
|
4 | 2 | use crate::build::matches::{Binding, Candidate, FlatPat, MatchPairTree, TestCase};
|
5 | 3 | use crate::build::Builder;
|
@@ -220,57 +218,6 @@ impl<'a, 'b, 'tcx> FakeBorrowCollector<'a, 'b, 'tcx> {
|
220 | 218 | }
|
221 | 219 | }
|
222 | 220 |
|
223 |
| -/// Visit all the bindings of these candidates. Because or-alternatives bind the same variables, we |
224 |
| -/// only explore the first one of each or-pattern. |
225 |
| -pub(super) fn visit_bindings<'tcx>( |
226 |
| - candidates: &[&mut Candidate<'_, 'tcx>], |
227 |
| - f: impl FnMut(&Binding<'tcx>), |
228 |
| -) { |
229 |
| - let mut visitor = BindingsVisitor { f, phantom: PhantomData }; |
230 |
| - for candidate in candidates.iter() { |
231 |
| - visitor.visit_candidate(candidate); |
232 |
| - } |
233 |
| -} |
234 |
| - |
235 |
| -pub(super) struct BindingsVisitor<'tcx, F> { |
236 |
| - f: F, |
237 |
| - phantom: PhantomData<&'tcx ()>, |
238 |
| -} |
239 |
| - |
240 |
| -impl<'tcx, F> BindingsVisitor<'tcx, F> |
241 |
| -where |
242 |
| - F: FnMut(&Binding<'tcx>), |
243 |
| -{ |
244 |
| - fn visit_candidate(&mut self, candidate: &Candidate<'_, 'tcx>) { |
245 |
| - for binding in &candidate.extra_data.bindings { |
246 |
| - (self.f)(binding) |
247 |
| - } |
248 |
| - for match_pair in &candidate.match_pairs { |
249 |
| - self.visit_match_pair(match_pair); |
250 |
| - } |
251 |
| - } |
252 |
| - |
253 |
| - fn visit_flat_pat(&mut self, flat_pat: &FlatPat<'_, 'tcx>) { |
254 |
| - for binding in &flat_pat.extra_data.bindings { |
255 |
| - (self.f)(binding) |
256 |
| - } |
257 |
| - for match_pair in &flat_pat.match_pairs { |
258 |
| - self.visit_match_pair(match_pair); |
259 |
| - } |
260 |
| - } |
261 |
| - |
262 |
| - fn visit_match_pair(&mut self, match_pair: &MatchPairTree<'_, 'tcx>) { |
263 |
| - if let TestCase::Or { pats, .. } = &match_pair.test_case { |
264 |
| - // All the or-alternatives should bind the same locals, so we only visit the first one. |
265 |
| - self.visit_flat_pat(&pats[0]) |
266 |
| - } else { |
267 |
| - for subpair in &match_pair.subpairs { |
268 |
| - self.visit_match_pair(subpair); |
269 |
| - } |
270 |
| - } |
271 |
| - } |
272 |
| -} |
273 |
| - |
274 | 221 | #[must_use]
|
275 | 222 | pub(crate) fn ref_pat_borrow_kind(ref_mutability: Mutability) -> BorrowKind {
|
276 | 223 | match ref_mutability {
|
|
0 commit comments