Trait chalk_ir::fold::TypeFoldable
source · pub trait TypeFoldable<I: Interner>: Debug + Sized {
// Required method
fn try_fold_with<E>(
self,
folder: &mut dyn FallibleTypeFolder<I, Error = E>,
outer_binder: DebruijnIndex,
) -> Result<Self, E>;
// Provided method
fn fold_with(
self,
folder: &mut dyn TypeFolder<I>,
outer_binder: DebruijnIndex,
) -> Self { ... }
}
Expand description
Applies the given TypeFolder
to a value, producing a folded result
of type Self::Result
. The result type is typically the same as
the source type, but in some cases we convert from borrowed
to owned as well (e.g., the folder for &T
will fold to a fresh
T
; well, actually T::Result
).
Required Methods§
sourcefn try_fold_with<E>(
self,
folder: &mut dyn FallibleTypeFolder<I, Error = E>,
outer_binder: DebruijnIndex,
) -> Result<Self, E>
fn try_fold_with<E>( self, folder: &mut dyn FallibleTypeFolder<I, Error = E>, outer_binder: DebruijnIndex, ) -> Result<Self, E>
Apply the given folder folder
to self
; binders
is the
number of binders that are in scope when beginning the
folder. Typically binders
starts as 0, but is adjusted when
we encounter Binders<T>
in the IR or other similar
constructs.
Provided Methods§
sourcefn fold_with(
self,
folder: &mut dyn TypeFolder<I>,
outer_binder: DebruijnIndex,
) -> Self
fn fold_with( self, folder: &mut dyn TypeFolder<I>, outer_binder: DebruijnIndex, ) -> Self
A convenient alternative to try_fold_with
for use with infallible
folders. Do not override this method, to ensure coherence with
try_fold_with
.
Object Safety§
Implementations on Foreign Types§
source§impl<A: TypeFoldable<I>, B: TypeFoldable<I>, C: TypeFoldable<I>, D: TypeFoldable<I>, E: TypeFoldable<I>, I: Interner> TypeFoldable<I> for (A, B, C, D, E)
impl<A: TypeFoldable<I>, B: TypeFoldable<I>, C: TypeFoldable<I>, D: TypeFoldable<I>, E: TypeFoldable<I>, I: Interner> TypeFoldable<I> for (A, B, C, D, E)
fn try_fold_with<Error>( self, folder: &mut dyn FallibleTypeFolder<I, Error = Error>, outer_binder: DebruijnIndex, ) -> Result<Self, Error>
source§impl<A: TypeFoldable<I>, B: TypeFoldable<I>, C: TypeFoldable<I>, D: TypeFoldable<I>, I: Interner> TypeFoldable<I> for (A, B, C, D)
impl<A: TypeFoldable<I>, B: TypeFoldable<I>, C: TypeFoldable<I>, D: TypeFoldable<I>, I: Interner> TypeFoldable<I> for (A, B, C, D)
fn try_fold_with<Error>( self, folder: &mut dyn FallibleTypeFolder<I, Error = Error>, outer_binder: DebruijnIndex, ) -> Result<Self, Error>
source§impl<A: TypeFoldable<I>, B: TypeFoldable<I>, C: TypeFoldable<I>, I: Interner> TypeFoldable<I> for (A, B, C)
impl<A: TypeFoldable<I>, B: TypeFoldable<I>, C: TypeFoldable<I>, I: Interner> TypeFoldable<I> for (A, B, C)
fn try_fold_with<Error>( self, folder: &mut dyn FallibleTypeFolder<I, Error = Error>, outer_binder: DebruijnIndex, ) -> Result<Self, Error>
source§impl<A: TypeFoldable<I>, B: TypeFoldable<I>, I: Interner> TypeFoldable<I> for (A, B)
impl<A: TypeFoldable<I>, B: TypeFoldable<I>, I: Interner> TypeFoldable<I> for (A, B)
fn try_fold_with<Error>( self, folder: &mut dyn FallibleTypeFolder<I, Error = Error>, outer_binder: DebruijnIndex, ) -> Result<Self, Error>
source§impl<I: Interner> TypeFoldable<I> for bool
impl<I: Interner> TypeFoldable<I> for bool
fn try_fold_with<E>( self, _folder: &mut dyn FallibleTypeFolder<I, Error = E>, _outer_binder: DebruijnIndex, ) -> Result<Self, E>
source§impl<I: Interner> TypeFoldable<I> for ()
impl<I: Interner> TypeFoldable<I> for ()
fn try_fold_with<E>( self, _folder: &mut dyn FallibleTypeFolder<I, Error = E>, _outer_binder: DebruijnIndex, ) -> Result<Self, E>
source§impl<I: Interner> TypeFoldable<I> for usize
impl<I: Interner> TypeFoldable<I> for usize
fn try_fold_with<E>( self, _folder: &mut dyn FallibleTypeFolder<I, Error = E>, _outer_binder: DebruijnIndex, ) -> Result<Self, E>
source§impl<I: Interner> TypeFoldable<I> for PhantomData<I>
impl<I: Interner> TypeFoldable<I> for PhantomData<I>
fn try_fold_with<E>( self, _folder: &mut dyn FallibleTypeFolder<I, Error = E>, _outer_binder: DebruijnIndex, ) -> Result<Self, E>
source§impl<T: TypeFoldable<I>, I: Interner> TypeFoldable<I> for Option<T>
impl<T: TypeFoldable<I>, I: Interner> TypeFoldable<I> for Option<T>
fn try_fold_with<E>( self, folder: &mut dyn FallibleTypeFolder<I, Error = E>, outer_binder: DebruijnIndex, ) -> Result<Self, E>
source§impl<T: TypeFoldable<I>, I: Interner> TypeFoldable<I> for Box<T>
impl<T: TypeFoldable<I>, I: Interner> TypeFoldable<I> for Box<T>
fn try_fold_with<E>( self, folder: &mut dyn FallibleTypeFolder<I, Error = E>, outer_binder: DebruijnIndex, ) -> Result<Self, E>
source§impl<T: TypeFoldable<I>, I: Interner> TypeFoldable<I> for Vec<T>
impl<T: TypeFoldable<I>, I: Interner> TypeFoldable<I> for Vec<T>
fn try_fold_with<E>( self, folder: &mut dyn FallibleTypeFolder<I, Error = E>, outer_binder: DebruijnIndex, ) -> Result<Self, E>
Implementors§
impl<G, _I> TypeFoldable<_I> for InEnvironment<G>
impl<I, T> TypeFoldable<I> for Canonical<T>
impl<I: Interner> TypeFoldable<I> for AliasTy<I>
impl<I: Interner> TypeFoldable<I> for ClausePriority
impl<I: Interner> TypeFoldable<I> for Constraint<I>
impl<I: Interner> TypeFoldable<I> for DomainGoal<I>
impl<I: Interner> TypeFoldable<I> for FloatTy
impl<I: Interner> TypeFoldable<I> for FromEnv<I>
impl<I: Interner> TypeFoldable<I> for GenericArgData<I>
impl<I: Interner> TypeFoldable<I> for GoalData<I>
impl<I: Interner> TypeFoldable<I> for IntTy
impl<I: Interner> TypeFoldable<I> for Mutability
impl<I: Interner> TypeFoldable<I> for QuantifierKind
impl<I: Interner> TypeFoldable<I> for Safety
impl<I: Interner> TypeFoldable<I> for Scalar
impl<I: Interner> TypeFoldable<I> for UintTy
impl<I: Interner> TypeFoldable<I> for WellFormed<I>
impl<I: Interner> TypeFoldable<I> for WhereClause<I>
impl<I: Interner> TypeFoldable<I> for AdtId<I>
impl<I: Interner> TypeFoldable<I> for AliasEq<I>
impl<I: Interner> TypeFoldable<I> for AnswerSubst<I>
impl<I: Interner> TypeFoldable<I> for AssocTypeId<I>
impl<I: Interner> TypeFoldable<I> for ClosureId<I>
impl<I: Interner> TypeFoldable<I> for Const<I>
“Folding” a const invokes the fold_const
method on the folder; this
usually (in turn) invokes super_fold_const
to fold the individual
parts.
impl<I: Interner> TypeFoldable<I> for ConstrainedSubst<I>
impl<I: Interner> TypeFoldable<I> for Constraints<I>
impl<I: Interner> TypeFoldable<I> for CoroutineId<I>
impl<I: Interner> TypeFoldable<I> for DebruijnIndex
impl<I: Interner> TypeFoldable<I> for DynTy<I>
impl<I: Interner> TypeFoldable<I> for Environment<I>
impl<I: Interner> TypeFoldable<I> for EqGoal<I>
impl<I: Interner> TypeFoldable<I> for FnDefId<I>
impl<I: Interner> TypeFoldable<I> for FnPointer<I>
impl<I: Interner> TypeFoldable<I> for FnSubst<I>
impl<I: Interner> TypeFoldable<I> for ForeignDefId<I>
impl<I: Interner> TypeFoldable<I> for GenericArg<I>
impl<I: Interner> TypeFoldable<I> for Goal<I>
Folding a goal invokes the fold_goal
callback (which will, by
default, invoke super-fold).
impl<I: Interner> TypeFoldable<I> for Goals<I>
impl<I: Interner> TypeFoldable<I> for ImplId<I>
impl<I: Interner> TypeFoldable<I> for Lifetime<I>
“Folding” a lifetime invokes the fold_lifetime
method on the folder; this
usually (in turn) invokes super_fold_lifetime
to fold the individual
parts.
impl<I: Interner> TypeFoldable<I> for LifetimeOutlives<I>
impl<I: Interner> TypeFoldable<I> for Normalize<I>
impl<I: Interner> TypeFoldable<I> for OpaqueTy<I>
impl<I: Interner> TypeFoldable<I> for OpaqueTyId<I>
impl<I: Interner> TypeFoldable<I> for PlaceholderIndex
impl<I: Interner> TypeFoldable<I> for ProgramClause<I>
Folding a program clause invokes the fold_program_clause
callback on the folder (which will, by default, invoke the
super_fold_with
method on the program clause).
impl<I: Interner> TypeFoldable<I> for ProgramClauseData<I>
impl<I: Interner> TypeFoldable<I> for ProgramClauseImplication<I>
impl<I: Interner> TypeFoldable<I> for ProgramClauses<I>
impl<I: Interner> TypeFoldable<I> for ProjectionTy<I>
impl<I: Interner> TypeFoldable<I> for QuantifiedWhereClauses<I>
impl<I: Interner> TypeFoldable<I> for Substitution<I>
impl<I: Interner> TypeFoldable<I> for SubtypeGoal<I>
impl<I: Interner> TypeFoldable<I> for TraitId<I>
impl<I: Interner> TypeFoldable<I> for TraitRef<I>
impl<I: Interner> TypeFoldable<I> for Ty<I>
“Folding” a type invokes the try_fold_ty
method on the folder; this
usually (in turn) invokes try_super_fold_ty
to fold the individual
parts.