Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
refactoring: move replace_base utility function to root of rustc_mi…
…r_transform crate.

incorporated review feedback: simplify replace_base via Place::project_deeper
  • Loading branch information
pnkfelix committed Aug 17, 2023
commit 6277dbb4ce250473b01b4e4b0d986e5256d2318b
9 changes: 1 addition & 8 deletions compiler/rustc_mir_transform/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,7 @@ impl<'tcx> MutVisitor<'tcx> for PinArgVisitor<'tcx> {
}
}

fn replace_base<'tcx>(place: &mut Place<'tcx>, new_base: Place<'tcx>, tcx: TyCtxt<'tcx>) {
place.local = new_base.local;

let mut new_projection = new_base.projection.to_vec();
new_projection.append(&mut place.projection.to_vec());

place.projection = tcx.mk_place_elems(&new_projection);
}
use crate::replace_base;

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

Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_mir_transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,3 +626,7 @@ fn promoted_mir(tcx: TyCtxt<'_>, def: LocalDefId) -> &IndexVec<Promoted, Body<'_

tcx.arena.alloc(promoted)
}

fn replace_base<'tcx>(place: &mut Place<'tcx>, new_base: Place<'tcx>, tcx: TyCtxt<'tcx>) {
*place = new_base.project_deeper(&place.projection[..], tcx)
}