diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 60c7c256ec74..047f338ab67c 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -2062,12 +2062,19 @@ impl<'tcx> Place<'tcx> { /// Recursively "iterates" over place components, generating a `PlaceComponents` list, /// invoking `op` with a `PlaceComponentsIter`. pub fn iterate( + &self, + op: impl FnOnce(PlaceComponentsIter<'_, 'tcx>) -> R, + ) -> R { + self.iterate2(None, op) + } + + fn iterate2( &self, next: Option<&PlaceComponents<'_, 'tcx>>, op: impl FnOnce(PlaceComponentsIter<'_, 'tcx>) -> R, ) -> R { match self { - Place::Projection(interior) => interior.base.iterate( + Place::Projection(interior) => interior.base.iterate2( Some(&PlaceComponents { component: self, next, diff --git a/src/librustc_mir/borrow_check/places_conflict.rs b/src/librustc_mir/borrow_check/places_conflict.rs index 45bbbbc92d9a..c498d7f7d968 100644 --- a/src/librustc_mir/borrow_check/places_conflict.rs +++ b/src/librustc_mir/borrow_check/places_conflict.rs @@ -67,8 +67,8 @@ pub(super) fn borrow_conflicts_with_place<'gcx, 'tcx>( } } - borrow_place.iterate(None, |borrow_components| { - access_place.iterate(None, |access_components| { + borrow_place.iterate(|borrow_components| { + access_place.iterate(|access_components| { place_components_conflict( tcx, mir,