Skip to content

Commit 5159b32

Browse files
committed
mir: remove a hacky recursive helper function
1 parent ddd4b19 commit 5159b32

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/librustc_mir/transform/promote_consts.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -310,16 +310,11 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
310310
match statement.kind {
311311
StatementKind::Assign(_, box Rvalue::Ref(_, _, ref mut place)) => {
312312
// Find the underlying local for this (necessarily interior) borrow.
313-
// HACK(eddyb) using a recursive function because of mutable borrows.
314-
fn interior_base<'a, 'tcx>(place: &'a mut Place<'tcx>)
315-
-> &'a mut Place<'tcx> {
316-
if let Place::Projection(ref mut proj) = *place {
317-
assert_ne!(proj.elem, ProjectionElem::Deref);
318-
return interior_base(&mut proj.base);
319-
}
320-
place
321-
}
322-
let place = interior_base(place);
313+
let mut place = place;
314+
while let Place::Projection(ref mut proj) = *place {
315+
assert_ne!(proj.elem, ProjectionElem::Deref);
316+
place = &mut proj.base;
317+
};
323318

324319
let ty = place.ty(local_decls, self.tcx).to_ty(self.tcx);
325320
let span = statement.source_info.span;

0 commit comments

Comments
 (0)