Skip to content

Commit cf6366b

Browse files
committed
Revert TypeVisitor changes
1 parent 0ee5a1a commit cf6366b

File tree

4 files changed

+39
-10
lines changed

4 files changed

+39
-10
lines changed

compiler/rustc_middle/src/infer/canonical.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,6 @@ pub struct Canonical<'tcx, V> {
4444

4545
pub type CanonicalVarInfos<'tcx> = &'tcx List<CanonicalVarInfo<'tcx>>;
4646

47-
impl<'tcx> ty::TypeFoldable<'tcx> for CanonicalVarInfos<'tcx> {
48-
fn try_fold_with<F: ty::FallibleTypeFolder<'tcx>>(
49-
self,
50-
folder: &mut F,
51-
) -> Result<Self, F::Error> {
52-
ty::util::fold_list(self, folder, |tcx, v| tcx.intern_canonical_var_infos(v))
53-
}
54-
}
55-
5647
/// A set of values corresponding to the canonical variables from some
5748
/// `Canonical`. You can give these values to
5849
/// `canonical_value.substitute` to substitute them into the canonical
@@ -314,6 +305,12 @@ TrivialTypeTraversalAndLiftImpls! {
314305
}
315306
}
316307

308+
TrivialTypeTraversalImpls! {
309+
for <'tcx> {
310+
crate::infer::canonical::CanonicalVarInfos<'tcx>,
311+
}
312+
}
313+
317314
impl<'tcx> CanonicalVarValues<'tcx> {
318315
#[inline]
319316
pub fn len(&self) -> usize {

compiler/rustc_middle/src/mir/type_visitable.rs

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ impl<'tcx, R: Idx, C: Idx> TypeVisitable<'tcx> for BitMatrix<R, C> {
88
}
99
}
1010

11+
impl<'tcx> TypeVisitable<'tcx> for &'tcx ty::List<PlaceElem<'tcx>> {
12+
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
13+
self.iter().try_for_each(|t| t.visit_with(visitor))
14+
}
15+
}
16+
1117
impl<'tcx> TypeVisitable<'tcx> for ConstantKind<'tcx> {
1218
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
1319
visitor.visit_mir_const(*self)

compiler/rustc_middle/src/ty/structural_impls.rs

+20
Original file line numberDiff line numberDiff line change
@@ -602,12 +602,26 @@ impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<ty::Binder<'tcx, ty::Existentia
602602
}
603603
}
604604

605+
impl<'tcx> TypeVisitable<'tcx>
606+
for &'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>>
607+
{
608+
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
609+
self.iter().try_for_each(|p| p.visit_with(visitor))
610+
}
611+
}
612+
605613
impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<ProjectionKind> {
606614
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
607615
ty::util::fold_list(self, folder, |tcx, v| tcx.intern_projs(v))
608616
}
609617
}
610618

619+
impl<'tcx> TypeVisitable<'tcx> for &'tcx ty::List<ProjectionKind> {
620+
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
621+
self.iter().try_for_each(|t| t.visit_with(visitor))
622+
}
623+
}
624+
611625
impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
612626
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
613627
folder.try_fold_ty(self)
@@ -783,6 +797,12 @@ impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<ty::Predicate<'tcx>> {
783797
}
784798
}
785799

800+
impl<'tcx> TypeVisitable<'tcx> for &'tcx ty::List<ty::Predicate<'tcx>> {
801+
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
802+
self.iter().try_for_each(|p| p.visit_with(visitor))
803+
}
804+
}
805+
786806
impl<'tcx, T: TypeFoldable<'tcx>, I: Idx> TypeFoldable<'tcx> for IndexVec<I, T> {
787807
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
788808
self.try_map_id(|x| x.try_fold_with(folder))

compiler/rustc_middle/src/ty/subst.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,12 @@ impl<'tcx> TypeFoldable<'tcx> for SubstsRef<'tcx> {
459459
}
460460
}
461461

462+
impl<'tcx> TypeVisitable<'tcx> for SubstsRef<'tcx> {
463+
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
464+
self.iter().try_for_each(|t| t.visit_with(visitor))
465+
}
466+
}
467+
462468
impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<Ty<'tcx>> {
463469
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
464470
// This code is fairly hot, though not as hot as `SubstsRef`.
@@ -491,7 +497,7 @@ impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<Ty<'tcx>> {
491497
}
492498
}
493499

494-
impl<'tcx, T: TypeVisitable<'tcx>> TypeVisitable<'tcx> for &'tcx ty::List<T> {
500+
impl<'tcx> TypeVisitable<'tcx> for &'tcx ty::List<Ty<'tcx>> {
495501
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
496502
self.iter().try_for_each(|t| t.visit_with(visitor))
497503
}

0 commit comments

Comments
 (0)