Skip to content

Commit 6359de1

Browse files
Link lifetime of closure param to that of self in Place::iterate
This informs callers that the lifetime of the reference to the underlying `PlaceBase` is the same as that of the `Place` being iterated over. This lets callers return a reference to the underlying `PlaceBase` from the closure passed to `Place::iterate`.
1 parent 0764641 commit 6359de1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/librustc/mir/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,17 +1915,17 @@ impl<'tcx> Place<'tcx> {
19151915

19161916
/// Recursively "iterates" over place components, generating a `PlaceBase` and
19171917
/// `Projections` list and invoking `op` with a `ProjectionsIter`.
1918-
pub fn iterate<R>(
1919-
&self,
1920-
op: impl FnOnce(&PlaceBase<'tcx>, ProjectionsIter<'_, 'tcx>) -> R,
1918+
pub fn iterate<'a, R: 'a>(
1919+
&'a self,
1920+
op: impl FnOnce(&'a PlaceBase<'tcx>, ProjectionsIter<'_, 'tcx>) -> R,
19211921
) -> R {
19221922
Place::iterate_over(&self.base, &self.projection, op)
19231923
}
19241924

1925-
pub fn iterate_over<R>(
1926-
place_base: &PlaceBase<'tcx>,
1925+
pub fn iterate_over<'a, R: 'a>(
1926+
place_base: &'a PlaceBase<'tcx>,
19271927
place_projection: &Option<Box<Projection<'tcx>>>,
1928-
op: impl FnOnce(&PlaceBase<'tcx>, ProjectionsIter<'_, 'tcx>) -> R,
1928+
op: impl FnOnce(&'a PlaceBase<'tcx>, ProjectionsIter<'_, 'tcx>) -> R,
19291929
) -> R {
19301930
fn iterate_over2<'tcx, R>(
19311931
place_base: &PlaceBase<'tcx>,

0 commit comments

Comments
 (0)