pub trait TypeVisitable<I: Interner>: Debug + Clone {
// Required method
fn visit_with<V: TypeVisitor<I>>(&self, visitor: &mut V) -> V::Result;
}
Expand description
This trait is implemented for every type that can be visited, providing the skeleton of the traversal.
To implement this conveniently, use the derive macro located in
rustc_macros
.
Required Methods§
sourcefn visit_with<V: TypeVisitor<I>>(&self, visitor: &mut V) -> V::Result
fn visit_with<V: TypeVisitor<I>>(&self, visitor: &mut V) -> V::Result
The entry point for visiting. To visit a value t
with a visitor v
call: t.visit_with(v)
.
For most types, this just traverses the value, calling visit_with
on
each field/element.
For types of interest (such as Ty
), the implementation of this method
that calls a visitor method specifically for that type (such as
V::visit_ty
). This is where control transfers from TypeVisitable
to
TypeVisitor
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
source§impl<I: Interner> TypeVisitable<I> for Movability
impl<I: Interner> TypeVisitable<I> for Movability
fn visit_with<F: TypeVisitor<I>>(&self, _: &mut F) -> F::Result
source§impl<I: Interner> TypeVisitable<I> for Mutability
impl<I: Interner> TypeVisitable<I> for Mutability
fn visit_with<F: TypeVisitor<I>>(&self, _: &mut F) -> F::Result
source§impl<I: Interner> TypeVisitable<I> for bool
impl<I: Interner> TypeVisitable<I> for bool
fn visit_with<F: TypeVisitor<I>>(&self, _: &mut F) -> F::Result
source§impl<I: Interner> TypeVisitable<I> for u16
impl<I: Interner> TypeVisitable<I> for u16
fn visit_with<F: TypeVisitor<I>>(&self, _: &mut F) -> F::Result
source§impl<I: Interner> TypeVisitable<I> for u32
impl<I: Interner> TypeVisitable<I> for u32
fn visit_with<F: TypeVisitor<I>>(&self, _: &mut F) -> F::Result
source§impl<I: Interner> TypeVisitable<I> for u64
impl<I: Interner> TypeVisitable<I> for u64
fn visit_with<F: TypeVisitor<I>>(&self, _: &mut F) -> F::Result
source§impl<I: Interner> TypeVisitable<I> for ()
impl<I: Interner> TypeVisitable<I> for ()
fn visit_with<F: TypeVisitor<I>>(&self, _: &mut F) -> F::Result
source§impl<I: Interner> TypeVisitable<I> for usize
impl<I: Interner> TypeVisitable<I> for usize
fn visit_with<F: TypeVisitor<I>>(&self, _: &mut F) -> F::Result
source§impl<I: Interner> TypeVisitable<I> for String
impl<I: Interner> TypeVisitable<I> for String
fn visit_with<F: TypeVisitor<I>>(&self, _: &mut F) -> F::Result
source§impl<I: Interner, A: TypeVisitable<I>, B: TypeVisitable<I>, C: TypeVisitable<I>> TypeVisitable<I> for (A, B, C)
impl<I: Interner, A: TypeVisitable<I>, B: TypeVisitable<I>, C: TypeVisitable<I>> TypeVisitable<I> for (A, B, C)
fn visit_with<V: TypeVisitor<I>>(&self, visitor: &mut V) -> V::Result
source§impl<I: Interner, T: TypeVisitable<I>> TypeVisitable<I> for &[T]
impl<I: Interner, T: TypeVisitable<I>> TypeVisitable<I> for &[T]
fn visit_with<V: TypeVisitor<I>>(&self, visitor: &mut V) -> V::Result
source§impl<I: Interner, T: TypeVisitable<I>> TypeVisitable<I> for Option<T>
impl<I: Interner, T: TypeVisitable<I>> TypeVisitable<I> for Option<T>
fn visit_with<V: TypeVisitor<I>>(&self, visitor: &mut V) -> V::Result
source§impl<I: Interner, T: TypeVisitable<I>> TypeVisitable<I> for Box<[T]>
impl<I: Interner, T: TypeVisitable<I>> TypeVisitable<I> for Box<[T]>
fn visit_with<V: TypeVisitor<I>>(&self, visitor: &mut V) -> V::Result
source§impl<I: Interner, T: TypeVisitable<I>> TypeVisitable<I> for Box<T>
impl<I: Interner, T: TypeVisitable<I>> TypeVisitable<I> for Box<T>
fn visit_with<V: TypeVisitor<I>>(&self, visitor: &mut V) -> V::Result
source§impl<I: Interner, T: TypeVisitable<I>> TypeVisitable<I> for Vec<T>
impl<I: Interner, T: TypeVisitable<I>> TypeVisitable<I> for Vec<T>
fn visit_with<V: TypeVisitor<I>>(&self, visitor: &mut V) -> V::Result
source§impl<I: Interner, T: TypeVisitable<I>> TypeVisitable<I> for ThinVec<T>
impl<I: Interner, T: TypeVisitable<I>> TypeVisitable<I> for ThinVec<T>
fn visit_with<V: TypeVisitor<I>>(&self, visitor: &mut V) -> V::Result
source§impl<I: Interner, T: TypeVisitable<I>, E: TypeVisitable<I>> TypeVisitable<I> for Result<T, E>
impl<I: Interner, T: TypeVisitable<I>, E: TypeVisitable<I>> TypeVisitable<I> for Result<T, E>
fn visit_with<V: TypeVisitor<I>>(&self, visitor: &mut V) -> V::Result
source§impl<I: Interner, T: TypeVisitable<I>, Ix: Idx> TypeVisitable<I> for IndexVec<Ix, T>
impl<I: Interner, T: TypeVisitable<I>, Ix: Idx> TypeVisitable<I> for IndexVec<Ix, T>
fn visit_with<V: TypeVisitor<I>>(&self, visitor: &mut V) -> V::Result
source§impl<I: Interner, T: TypeVisitable<I>, U: TypeVisitable<I>> TypeVisitable<I> for (T, U)
impl<I: Interner, T: TypeVisitable<I>, U: TypeVisitable<I>> TypeVisitable<I> for (T, U)
fn visit_with<V: TypeVisitor<I>>(&self, visitor: &mut V) -> V::Result
Implementors§
impl<I> TypeVisitable<I> for CanonicalTyVarKindwhere
I: Interner,
impl<I> TypeVisitable<I> for CanonicalVarKind<I>where
I: Interner,
I::PlaceholderTy: TypeVisitable<I>,
I::PlaceholderRegion: TypeVisitable<I>,
I::PlaceholderConst: TypeVisitable<I>,
impl<I> TypeVisitable<I> for TypeError<I>where
I: Interner,
ExpectedFound<I::Safety>: TypeVisitable<I>,
ExpectedFound<I::Abi>: TypeVisitable<I>,
I::Region: TypeVisitable<I>,
I::BoundRegion: TypeVisitable<I>,
ExpectedFound<I::Ty>: TypeVisitable<I>,
ExpectedFound<I::DefId>: TypeVisitable<I>,
I::Ty: TypeVisitable<I>,
I::Const: TypeVisitable<I>,
ExpectedFound<I::BoundExistentialPredicates>: TypeVisitable<I>,
ExpectedFound<I::Const>: TypeVisitable<I>,
I::DefId: TypeVisitable<I>,
impl<I> TypeVisitable<I> for ExistentialPredicate<I>where
I: Interner,
ExistentialTraitRef<I>: TypeVisitable<I>,
ExistentialProjection<I>: TypeVisitable<I>,
I::DefId: TypeVisitable<I>,
impl<I> TypeVisitable<I> for ClauseKind<I>where
I: Interner,
TraitPredicate<I>: TypeVisitable<I>,
OutlivesPredicate<I, I::Region>: TypeVisitable<I>,
OutlivesPredicate<I, I::Ty>: TypeVisitable<I>,
ProjectionPredicate<I>: TypeVisitable<I>,
I::Const: TypeVisitable<I>,
I::Ty: TypeVisitable<I>,
I::GenericArg: TypeVisitable<I>,
impl<I> TypeVisitable<I> for PredicateKind<I>where
I: Interner,
ClauseKind<I>: TypeVisitable<I>,
I::DefId: TypeVisitable<I>,
SubtypePredicate<I>: TypeVisitable<I>,
CoercePredicate<I>: TypeVisitable<I>,
I::Const: TypeVisitable<I>,
NormalizesTo<I>: TypeVisitable<I>,
I::Term: TypeVisitable<I>,
impl<I> TypeVisitable<I> for ProbeKind<I>
impl<I> TypeVisitable<I> for CanonicalVarInfo<I>
impl<I> TypeVisitable<I> for CanonicalVarValues<I>
impl<I> TypeVisitable<I> for UnevaluatedConst<I>
impl<I> TypeVisitable<I> for OpaqueTypeKey<I>
impl<I> TypeVisitable<I> for AliasTerm<I>
impl<I> TypeVisitable<I> for CoercePredicate<I>
impl<I> TypeVisitable<I> for ExistentialProjection<I>where
I: Interner,
I::DefId: TypeVisitable<I>,
I::GenericArgs: TypeVisitable<I>,
I::Term: TypeVisitable<I>,
impl<I> TypeVisitable<I> for ExistentialTraitRef<I>
impl<I> TypeVisitable<I> for NormalizesTo<I>
impl<I> TypeVisitable<I> for ProjectionPredicate<I>
impl<I> TypeVisitable<I> for SubtypePredicate<I>
impl<I> TypeVisitable<I> for TraitPredicate<I>
impl<I> TypeVisitable<I> for TraitRef<I>
impl<I> TypeVisitable<I> for ExternalConstraintsData<I>where
I: Interner,
Vec<OutlivesPredicate<I, I::GenericArg>>: TypeVisitable<I>,
Vec<(OpaqueTypeKey<I>, I::Ty)>: TypeVisitable<I>,
NestedNormalizationGoals<I>: TypeVisitable<I>,
impl<I> TypeVisitable<I> for NestedNormalizationGoals<I>
impl<I> TypeVisitable<I> for PredefinedOpaquesData<I>
impl<I> TypeVisitable<I> for Response<I>where
I: Interner,
CanonicalVarValues<I>: TypeVisitable<I>,
I::ExternalConstraints: TypeVisitable<I>,
impl<I> TypeVisitable<I> for ClosureArgs<I>
impl<I> TypeVisitable<I> for CoroutineArgs<I>
impl<I> TypeVisitable<I> for CoroutineClosureArgs<I>
impl<I> TypeVisitable<I> for CoroutineClosureSignature<I>
impl<I> TypeVisitable<I> for GenSig<I>
impl<I> TypeVisitable<I> for AliasTy<I>
impl<I> TypeVisitable<I> for FnHeader<I>
impl<I> TypeVisitable<I> for FnSig<I>
impl<I> TypeVisitable<I> for FnSigTys<I>
impl<I> TypeVisitable<I> for TypeAndMut<I>
impl<I, A> TypeVisitable<I> for OutlivesPredicate<I, A>
impl<I, P> TypeVisitable<I> for Goal<I, P>
impl<I, P> TypeVisitable<I> for QueryInput<I, P>
impl<I, T> TypeVisitable<I> for State<I, T>
impl<I, V> TypeVisitable<I> for Canonical<I, V>
impl<I: Interner> TypeVisitable<I> for Variance
impl<I: Interner> TypeVisitable<I> for BoundConstness
impl<I: Interner> TypeVisitable<I> for PredicatePolarity
impl<I: Interner> TypeVisitable<I> for AliasRelationDirection
impl<I: Interner> TypeVisitable<I> for BuiltinImplSource
impl<I: Interner> TypeVisitable<I> for Certainty
impl<I: Interner> TypeVisitable<I> for GoalSource
impl<I: Interner> TypeVisitable<I> for MaybeCause
impl<I: Interner> TypeVisitable<I> for AliasTyKind
impl<I: Interner> TypeVisitable<I> for FloatTy
impl<I: Interner> TypeVisitable<I> for InferTy
impl<I: Interner> TypeVisitable<I> for IntVarValue
impl<I: Interner> TypeVisitable<I> for RegionVid
impl<I: Interner> TypeVisitable<I> for NoSolution
impl<I: Interner> TypeVisitable<I> for DebruijnIndex
impl<I: Interner> TypeVisitable<I> for UniverseIndex
impl<I: Interner, T> !TypeVisitable<I> for EarlyBinder<I, T>
For early binders, you should first call instantiate
before using any visitors.