Trait rustc_middle::ty::fold::TypeFolder
source · [−]pub trait TypeFolder<'tcx>: Sized {
type Error = !;
fn tcx<'a>(&'a self) -> TyCtxt<'tcx>;
fn fold_binder<T>(&mut self, t: Binder<'tcx, T>) -> Binder<'tcx, T>
where
T: TypeFoldable<'tcx>,
Self: TypeFolder<'tcx, Error = !>,
{ ... }
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx>
where
Self: TypeFolder<'tcx, Error = !>,
{ ... }
fn fold_region(&mut self, r: Region<'tcx>) -> Region<'tcx>
where
Self: TypeFolder<'tcx, Error = !>,
{ ... }
fn fold_const(&mut self, c: Const<'tcx>) -> Const<'tcx>
where
Self: TypeFolder<'tcx, Error = !>,
{ ... }
fn fold_predicate(&mut self, p: Predicate<'tcx>) -> Predicate<'tcx>
where
Self: TypeFolder<'tcx, Error = !>,
{ ... }
fn fold_mir_const(&mut self, c: ConstantKind<'tcx>) -> ConstantKind<'tcx>
where
Self: TypeFolder<'tcx, 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.
If this folder is fallible (and therefore its Error
associated type is something other than the default !) then
FallibleTypeFolder should be implemented manually. Otherwise,
a blanket implementation of FallibleTypeFolder will defer to
the infallible methods of this trait to ensure that the two APIs
are coherent.