Do not ICE on deeply nested borrows.

This commit is contained in:
Camille GILLOT 2023-05-13 10:29:05 +00:00
parent 19652377c3
commit 13fb0794ac
2 changed files with 17 additions and 2 deletions

View file

@ -363,8 +363,10 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'tcx> {
if let Some((&PlaceElem::Deref, rest)) = target.projection.split_last() {
*place = Place::from(target.local).project_deeper(rest, self.tcx);
self.any_replacement = true;
} else if self.fully_replacable_locals.contains(place.local) {
debuginfo.references += 1;
} else if self.fully_replacable_locals.contains(place.local)
&& let Some(references) = debuginfo.references.checked_add(1)
{
debuginfo.references = references;
*place = target;
self.any_replacement = true;
}