Skip to content

Commit 6277dbb

Browse files
committed
refactoring: move replace_base utility function to root of rustc_mir_transform crate.
incorporated review feedback: simplify replace_base via Place::project_deeper
1 parent bd138e2 commit 6277dbb

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

compiler/rustc_mir_transform/src/generator.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,7 @@ impl<'tcx> MutVisitor<'tcx> for PinArgVisitor<'tcx> {
182182
}
183183
}
184184

185-
fn replace_base<'tcx>(place: &mut Place<'tcx>, new_base: Place<'tcx>, tcx: TyCtxt<'tcx>) {
186-
place.local = new_base.local;
187-
188-
let mut new_projection = new_base.projection.to_vec();
189-
new_projection.append(&mut place.projection.to_vec());
190-
191-
place.projection = tcx.mk_place_elems(&new_projection);
192-
}
185+
use crate::replace_base;
193186

194187
const SELF_ARG: Local = Local::from_u32(1);
195188

compiler/rustc_mir_transform/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,3 +626,7 @@ fn promoted_mir(tcx: TyCtxt<'_>, def: LocalDefId) -> &IndexVec<Promoted, Body<'_
626626

627627
tcx.arena.alloc(promoted)
628628
}
629+
630+
fn replace_base<'tcx>(place: &mut Place<'tcx>, new_base: Place<'tcx>, tcx: TyCtxt<'tcx>) {
631+
*place = new_base.project_deeper(&place.projection[..], tcx)
632+
}

0 commit comments

Comments
 (0)