rustc_middle::ty::fold

Trait FallibleTypeFolder

pub trait FallibleTypeFolder<I>: Sized
where I: Interner,
{ type Error; // Required method fn cx(&self) -> I; // Provided methods fn try_fold_binder<T>( &mut self, t: Binder<I, T>, ) -> Result<Binder<I, T>, Self::Error> where T: TypeFoldable<I> { ... } fn try_fold_ty( &mut self, t: <I as Interner>::Ty, ) -> Result<<I as Interner>::Ty, Self::Error> { ... } fn try_fold_region( &mut self, r: <I as Interner>::Region, ) -> Result<<I as Interner>::Region, Self::Error> { ... } fn try_fold_const( &mut self, c: <I as Interner>::Const, ) -> Result<<I as Interner>::Const, Self::Error> { ... } fn try_fold_predicate( &mut self, p: <I as Interner>::Predicate, ) -> Result<<I as Interner>::Predicate, Self::Error> { ... } }
Expand description

This trait is implemented for every folding traversal. There is a fold method defined for every type of interest. Each such method has a default that does an “identity” fold.

A blanket implementation of this trait (that defers to the relevant method of TypeFolder) is provided for all infallible folders in order to ensure the two APIs are coherent.

Required Associated Types§

type Error

Required Methods§

fn cx(&self) -> I

Provided Methods§

fn try_fold_binder<T>( &mut self, t: Binder<I, T>, ) -> Result<Binder<I, T>, Self::Error>
where T: TypeFoldable<I>,

fn try_fold_ty( &mut self, t: <I as Interner>::Ty, ) -> Result<<I as Interner>::Ty, Self::Error>

fn try_fold_region( &mut self, r: <I as Interner>::Region, ) -> Result<<I as Interner>::Region, Self::Error>

fn try_fold_const( &mut self, c: <I as Interner>::Const, ) -> Result<<I as Interner>::Const, Self::Error>

fn try_fold_predicate( &mut self, p: <I as Interner>::Predicate, ) -> Result<<I as Interner>::Predicate, Self::Error>

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.

Implementors§