From: Santiago Pastorino Date: Wed, 27 Feb 2019 20:27:50 +0000 (+0100) Subject: Place::iterate do not take an accumulator anymore, hide that in a private fn X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=0326f0a80359ec13c4d0716ed6b375506703ba20;p=rust.git Place::iterate do not take an accumulator anymore, hide that in a private fn --- diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 60c7c256ec7..047f338ab67 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -2062,12 +2062,19 @@ pub fn base_local(&self) -> Option { /// 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 45bbbbc92d9..c498d7f7d96 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,