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§

source

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§

source

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§

This trait is not object safe.

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)

source§

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)

source§

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)

source§

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)

source§

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

source§

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 ()

source§

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

source§

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>

source§

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>

source§

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>

source§

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>

source§

fn try_fold_with<E>( self, folder: &mut dyn FallibleTypeFolder<I, Error = E>, outer_binder: DebruijnIndex, ) -> Result<Self, E>

Implementors§

source§

impl<G, _I> TypeFoldable<_I> for InEnvironment<G>
where _I: Interner, G: HasInterner<Interner = _I> + TypeFoldable<_I> + HasInterner,

source§

impl<I, T> TypeFoldable<I> for Canonical<T>
where I: Interner, T: HasInterner<Interner = I> + TypeFoldable<I>,

source§

impl<I: Interner> TypeFoldable<I> for AliasTy<I>

source§

impl<I: Interner> TypeFoldable<I> for ClausePriority

source§

impl<I: Interner> TypeFoldable<I> for Constraint<I>

source§

impl<I: Interner> TypeFoldable<I> for DomainGoal<I>

source§

impl<I: Interner> TypeFoldable<I> for FloatTy

source§

impl<I: Interner> TypeFoldable<I> for FromEnv<I>

source§

impl<I: Interner> TypeFoldable<I> for GenericArgData<I>

source§

impl<I: Interner> TypeFoldable<I> for GoalData<I>

source§

impl<I: Interner> TypeFoldable<I> for IntTy

source§

impl<I: Interner> TypeFoldable<I> for Mutability

source§

impl<I: Interner> TypeFoldable<I> for QuantifierKind

source§

impl<I: Interner> TypeFoldable<I> for Safety

source§

impl<I: Interner> TypeFoldable<I> for Scalar

source§

impl<I: Interner> TypeFoldable<I> for UintTy

source§

impl<I: Interner> TypeFoldable<I> for WellFormed<I>

source§

impl<I: Interner> TypeFoldable<I> for WhereClause<I>

source§

impl<I: Interner> TypeFoldable<I> for AdtId<I>

source§

impl<I: Interner> TypeFoldable<I> for AliasEq<I>

source§

impl<I: Interner> TypeFoldable<I> for AnswerSubst<I>

source§

impl<I: Interner> TypeFoldable<I> for AssocTypeId<I>

source§

impl<I: Interner> TypeFoldable<I> for ClosureId<I>

source§

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.

source§

impl<I: Interner> TypeFoldable<I> for ConstrainedSubst<I>

source§

impl<I: Interner> TypeFoldable<I> for Constraints<I>

source§

impl<I: Interner> TypeFoldable<I> for CoroutineId<I>

source§

impl<I: Interner> TypeFoldable<I> for DebruijnIndex

source§

impl<I: Interner> TypeFoldable<I> for DynTy<I>

source§

impl<I: Interner> TypeFoldable<I> for Environment<I>

source§

impl<I: Interner> TypeFoldable<I> for EqGoal<I>

source§

impl<I: Interner> TypeFoldable<I> for FnDefId<I>

source§

impl<I: Interner> TypeFoldable<I> for FnPointer<I>

source§

impl<I: Interner> TypeFoldable<I> for FnSubst<I>

source§

impl<I: Interner> TypeFoldable<I> for ForeignDefId<I>

source§

impl<I: Interner> TypeFoldable<I> for GenericArg<I>

source§

impl<I: Interner> TypeFoldable<I> for Goal<I>

Folding a goal invokes the fold_goal callback (which will, by default, invoke super-fold).

source§

impl<I: Interner> TypeFoldable<I> for Goals<I>

source§

impl<I: Interner> TypeFoldable<I> for ImplId<I>

source§

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.

source§

impl<I: Interner> TypeFoldable<I> for LifetimeOutlives<I>

source§

impl<I: Interner> TypeFoldable<I> for Normalize<I>

source§

impl<I: Interner> TypeFoldable<I> for OpaqueTy<I>

source§

impl<I: Interner> TypeFoldable<I> for OpaqueTyId<I>

source§

impl<I: Interner> TypeFoldable<I> for PlaceholderIndex

source§

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).

source§

impl<I: Interner> TypeFoldable<I> for ProgramClauseData<I>

source§

impl<I: Interner> TypeFoldable<I> for ProgramClauseImplication<I>

source§

impl<I: Interner> TypeFoldable<I> for ProgramClauses<I>

source§

impl<I: Interner> TypeFoldable<I> for ProjectionTy<I>

source§

impl<I: Interner> TypeFoldable<I> for QuantifiedWhereClauses<I>

source§

impl<I: Interner> TypeFoldable<I> for Substitution<I>

source§

impl<I: Interner> TypeFoldable<I> for SubtypeGoal<I>

source§

impl<I: Interner> TypeFoldable<I> for TraitId<I>

source§

impl<I: Interner> TypeFoldable<I> for TraitRef<I>

source§

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.

source§

impl<I: Interner> TypeFoldable<I> for TypeOutlives<I>

source§

impl<I: Interner> TypeFoldable<I> for UniverseIndex

source§

impl<T, I> TypeFoldable<I> for Binders<T>
where T: HasInterner<Interner = I> + TypeFoldable<I>, I: Interner,