Rollup merge of #116792 - JonasAlaif:renumber-fix, r=b-naber
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.
This commit is contained in:
commit
61ff4dbedd
@ -81,6 +81,10 @@ impl<'a, 'tcx> MutVisitor<'tcx> for RegionRenumberer<'a, 'tcx> {
|
|||||||
|
|
||||||
#[instrument(skip(self), level = "debug")]
|
#[instrument(skip(self), level = "debug")]
|
||||||
fn visit_ty(&mut self, ty: &mut Ty<'tcx>, ty_context: TyContext) {
|
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));
|
*ty = self.renumber_regions(*ty, || RegionCtxt::TyContext(ty_context));
|
||||||
|
|
||||||
debug!(?ty);
|
debug!(?ty);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user