Skip to content

Commit b4c342e

Browse files
committed
Simplify visit_place.
1 parent 6d73041 commit b4c342e

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

compiler/rustc_mir_transform/src/ref_prop.rs

+13-14
Original file line numberDiff line numberDiff line change
@@ -374,23 +374,22 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'tcx> {
374374
}
375375

376376
fn visit_place(&mut self, place: &mut Place<'tcx>, ctxt: PlaceContext, loc: Location) {
377-
if place.projection.first() != Some(&PlaceElem::Deref) {
378-
return;
379-
}
380-
381377
loop {
382-
if let Value::Pointer(target, _) = self.targets[place.local] {
383-
let perform_opt = matches!(ctxt, PlaceContext::NonUse(_))
384-
|| self.allowed_replacements.contains(&(target.local, loc));
385-
386-
if perform_opt {
387-
*place = target.project_deeper(&place.projection[1..], self.tcx);
388-
self.any_replacement = true;
389-
continue;
390-
}
378+
if place.projection.first() != Some(&PlaceElem::Deref) {
379+
return;
380+
}
381+
382+
let Value::Pointer(target, _) = self.targets[place.local] else { return };
383+
384+
let perform_opt = matches!(ctxt, PlaceContext::NonUse(_))
385+
|| self.allowed_replacements.contains(&(target.local, loc));
386+
387+
if !perform_opt {
388+
return;
391389
}
392390

393-
break;
391+
*place = target.project_deeper(&place.projection[1..], self.tcx);
392+
self.any_replacement = true;
394393
}
395394
}
396395

0 commit comments

Comments
 (0)