Skip to content

Commit

Permalink
Rollup merge of rust-lang#116792 - JonasAlaif:renumber-fix, r=b-naber
Browse files Browse the repository at this point in the history
Avoid unnecessary renumbering during borrowck

Currently, after renumbering there are always unused `RegionVid`s if the return type contains any regions, this is due to `visit_ty` being called twice on the same `Ty`: once with `TyContext::ReturnTy` and once with `TyContext::LocalDecl { local: _0 }`. This PR skips renumbering the first time around.
  • Loading branch information
matthiaskrgr committed Oct 24, 2023
2 parents 65297e0 + 2bba98b commit b090dc7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions compiler/rustc_borrowck/src/renumber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ impl<'a, 'tcx> MutVisitor<'tcx> for RegionRenumberer<'a, 'tcx> {

#[instrument(skip(self), level = "debug")]
fn visit_ty(&mut self, ty: &mut Ty<'tcx>, ty_context: TyContext) {
if matches!(ty_context, TyContext::ReturnTy(_)) {
// We will renumber the return ty when called again with `TyContext::LocalDecl`
return;
}
*ty = self.renumber_regions(*ty, || RegionCtxt::TyContext(ty_context));

debug!(?ty);
Expand Down

0 comments on commit b090dc7

Please sign in to comment.