do not implement type traversal for EarlyBinder

This commit is contained in:
lcnr 2022-09-16 15:09:38 +02:00
parent efa717bc2d
commit d398b54de6
3 changed files with 8 additions and 13 deletions

View File

@ -2770,7 +2770,10 @@ impl<'tcx> ty::Instance<'tcx> {
// track of a polymorphization `ParamEnv` to allow normalizing later.
let mut sig = match *ty.kind() {
ty::FnDef(def_id, substs) => tcx
.normalize_erasing_regions(tcx.param_env(def_id), tcx.bound_fn_sig(def_id))
.bound_fn_sig(def_id)
.map_bound(|fn_sig| {
tcx.normalize_erasing_regions(tcx.param_env(def_id), fn_sig)
})
.subst(tcx, substs),
_ => unreachable!(),
};

View File

@ -557,18 +557,6 @@ impl<'tcx, T: TypeVisitable<'tcx>> TypeVisitable<'tcx> for Box<[T]> {
}
}
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::EarlyBinder<T> {
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
self.try_map_bound(|ty| ty.try_fold_with(folder))
}
}
impl<'tcx, T: TypeVisitable<'tcx>> TypeVisitable<'tcx> for ty::EarlyBinder<T> {
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
self.as_ref().0.visit_with(visitor)
}
}
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<'tcx, T> {
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
folder.try_fold_binder(self)

View File

@ -919,6 +919,10 @@ impl<'tcx> PolyExistentialTraitRef<'tcx> {
#[derive(Encodable, Decodable, HashStable)]
pub struct EarlyBinder<T>(pub T);
/// For early binders, you should first call `subst` before using any visitors.
impl<'tcx, T> !TypeFoldable<'tcx> for ty::EarlyBinder<T> {}
impl<'tcx, T> !TypeVisitable<'tcx> for ty::EarlyBinder<T> {}
impl<T> EarlyBinder<T> {
pub fn as_ref(&self) -> EarlyBinder<&T> {
EarlyBinder(&self.0)