Skip to content

Commit d398b54

Browse files
committed
do not implement type traversal for EarlyBinder
1 parent efa717b commit d398b54

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

compiler/rustc_middle/src/ty/layout.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -2770,7 +2770,10 @@ impl<'tcx> ty::Instance<'tcx> {
27702770
// track of a polymorphization `ParamEnv` to allow normalizing later.
27712771
let mut sig = match *ty.kind() {
27722772
ty::FnDef(def_id, substs) => tcx
2773-
.normalize_erasing_regions(tcx.param_env(def_id), tcx.bound_fn_sig(def_id))
2773+
.bound_fn_sig(def_id)
2774+
.map_bound(|fn_sig| {
2775+
tcx.normalize_erasing_regions(tcx.param_env(def_id), fn_sig)
2776+
})
27742777
.subst(tcx, substs),
27752778
_ => unreachable!(),
27762779
};

compiler/rustc_middle/src/ty/structural_impls.rs

-12
Original file line numberDiff line numberDiff line change
@@ -557,18 +557,6 @@ impl<'tcx, T: TypeVisitable<'tcx>> TypeVisitable<'tcx> for Box<[T]> {
557557
}
558558
}
559559

560-
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::EarlyBinder<T> {
561-
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
562-
self.try_map_bound(|ty| ty.try_fold_with(folder))
563-
}
564-
}
565-
566-
impl<'tcx, T: TypeVisitable<'tcx>> TypeVisitable<'tcx> for ty::EarlyBinder<T> {
567-
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
568-
self.as_ref().0.visit_with(visitor)
569-
}
570-
}
571-
572560
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<'tcx, T> {
573561
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
574562
folder.try_fold_binder(self)

compiler/rustc_middle/src/ty/sty.rs

+4
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,10 @@ impl<'tcx> PolyExistentialTraitRef<'tcx> {
919919
#[derive(Encodable, Decodable, HashStable)]
920920
pub struct EarlyBinder<T>(pub T);
921921

922+
/// For early binders, you should first call `subst` before using any visitors.
923+
impl<'tcx, T> !TypeFoldable<'tcx> for ty::EarlyBinder<T> {}
924+
impl<'tcx, T> !TypeVisitable<'tcx> for ty::EarlyBinder<T> {}
925+
922926
impl<T> EarlyBinder<T> {
923927
pub fn as_ref(&self) -> EarlyBinder<&T> {
924928
EarlyBinder(&self.0)

0 commit comments

Comments
 (0)