remove ct.has_vars_bound_at_or_above calls

`ty::Const` doesn't have precomputed type flags, so
computing `has_vars_bound_at_or_above` for constants
requires us to visit the const and its contained types
and constants. A noop fold should be pretty much equally as
fast so removing it prevents us from walking the constant twice
in case it contains bound vars.
This commit is contained in:
lcnr 2022-07-14 12:35:09 +02:00
parent 1c7b36d4db
commit 39a990d2f1
2 changed files with 2 additions and 4 deletions

View File

@ -445,8 +445,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for BoundVarReplacer<'a, 'tcx> {
let ct = (self.fld_c)(bound_const, ct.ty());
ty::fold::shift_vars(self.tcx, ct, self.current_index.as_u32())
}
_ if ct.has_vars_bound_at_or_above(self.current_index) => ct.super_fold_with(self),
_ => ct,
_ => ct.super_fold_with(self),
}
}
}

View File

@ -753,8 +753,7 @@ impl<'tcx> TypeFolder<'tcx> for BoundVarReplacer<'_, 'tcx> {
.tcx
.mk_const(ty::ConstS { kind: ty::ConstKind::Placeholder(p), ty: ct.ty() })
}
_ if ct.has_vars_bound_at_or_above(self.current_index) => ct.super_fold_with(self),
_ => ct,
_ => ct.super_fold_with(self),
}
}
}