mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-08 16:07:43 +00:00
mir: remove a hacky recursive helper function
This commit is contained in:
parent
ddd4b194a0
commit
5159b32997
@ -310,16 +310,11 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
|
|||||||
match statement.kind {
|
match statement.kind {
|
||||||
StatementKind::Assign(_, box Rvalue::Ref(_, _, ref mut place)) => {
|
StatementKind::Assign(_, box Rvalue::Ref(_, _, ref mut place)) => {
|
||||||
// Find the underlying local for this (necessarily interior) borrow.
|
// Find the underlying local for this (necessarily interior) borrow.
|
||||||
// HACK(eddyb) using a recursive function because of mutable borrows.
|
let mut place = place;
|
||||||
fn interior_base<'a, 'tcx>(place: &'a mut Place<'tcx>)
|
while let Place::Projection(ref mut proj) = *place {
|
||||||
-> &'a mut Place<'tcx> {
|
assert_ne!(proj.elem, ProjectionElem::Deref);
|
||||||
if let Place::Projection(ref mut proj) = *place {
|
place = &mut proj.base;
|
||||||
assert_ne!(proj.elem, ProjectionElem::Deref);
|
};
|
||||||
return interior_base(&mut proj.base);
|
|
||||||
}
|
|
||||||
place
|
|
||||||
}
|
|
||||||
let place = interior_base(place);
|
|
||||||
|
|
||||||
let ty = place.ty(local_decls, self.tcx).to_ty(self.tcx);
|
let ty = place.ty(local_decls, self.tcx).to_ty(self.tcx);
|
||||||
let span = statement.source_info.span;
|
let span = statement.source_info.span;
|
||||||
|
Loading…
Reference in New Issue
Block a user