rustc_type_ir::fold

Trait TypeFolder

Source
pub trait TypeFolder<I: Interner>: FallibleTypeFolder<I, Error = !> {
    // Required method
    fn cx(&self) -> I;

    // Provided methods
    fn fold_binder<T>(&mut self, t: Binder<I, T>) -> Binder<I, T>
       where T: TypeFoldable<I> { ... }
    fn fold_ty(&mut self, t: I::Ty) -> I::Ty { ... }
    fn fold_region(&mut self, r: I::Region) -> I::Region { ... }
    fn fold_const(&mut self, c: I::Const) -> I::Const { ... }
    fn fold_predicate(&mut self, p: I::Predicate) -> I::Predicate { ... }
}
Expand description

This trait is implemented for every infallible folding traversal. There is a fold method defined for every type of interest. Each such method has a default that does an “identity” fold. Implementations of these methods often fall back to a super_fold_with method if the primary argument doesn’t satisfy a particular condition.

A blanket implementation of FallibleTypeFolder will defer to the infallible methods of this trait to ensure that the two APIs are coherent.

Required Methods§

Source

fn cx(&self) -> I

Provided Methods§

Source

fn fold_binder<T>(&mut self, t: Binder<I, T>) -> Binder<I, T>
where T: TypeFoldable<I>,

Source

fn fold_ty(&mut self, t: I::Ty) -> I::Ty

Source

fn fold_region(&mut self, r: I::Region) -> I::Region

Source

fn fold_const(&mut self, c: I::Const) -> I::Const

Source

fn fold_predicate(&mut self, p: I::Predicate) -> I::Predicate

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§

Source§

impl<'a, I: Interner> TypeFolder<I> for ArgFolder<'a, I>

Source§

impl<I: Interner> TypeFolder<I> for FoldEscapingRegions<I>

Source§

impl<I: Interner> TypeFolder<I> for Shifter<I>

impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for TyVarReplacer<'cx, 'tcx>

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Anonymize<'tcx>

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for RemapLateBound<'_, 'tcx>

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReplaceTy<'tcx>

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for AssocTyToOpaque<'tcx>

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for MapAndCompressBoundVars<'tcx>

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ParamIndexRemapper<'tcx>

impl<'tcx, E> TypeFolder<TyCtxt<'tcx>> for ImplTraitInTraitCollector<'_, 'tcx, E>
where E: 'tcx,

impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Resolver<'cx, 'tcx>

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for EagerlyNormalizeConsts<'tcx>

impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for TypeFreshener<'a, 'tcx>

impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for OpportunisticRegionResolver<'a, 'tcx>

impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for OpportunisticVarResolver<'a, 'tcx>

impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for InferenceFudger<'a, 'tcx>

impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx>

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for InferenceLiteralEraser<'tcx>

impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for RegionFolder<'a, 'tcx>

impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for RegionFolder<'a, 'tcx>

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for RegionEraserVisitor<'tcx>

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx>

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for OpaqueTypeExpander<'tcx>

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for WeakAliasTypeExpander<'tcx>

impl<'tcx, D> TypeFolder<TyCtxt<'tcx>> for BoundVarReplacer<'tcx, D>
where D: BoundVarReplacerDelegate<'tcx>,

impl<'tcx, F, G, H> TypeFolder<TyCtxt<'tcx>> for BottomUpFolder<'tcx, F, G, H>
where F: FnMut(Ty<'tcx>) -> Ty<'tcx>, G: FnMut(Region<'tcx>) -> Region<'tcx>, H: FnMut(Const<'tcx>) -> Const<'tcx>,

impl<D, I> TypeFolder<I> for ReplaceAliasWithInfer<'_, '_, D, I>
where D: SolverDelegate<Interner = I>, I: Interner,

impl<D: SolverDelegate<Interner = I>, I: Interner> TypeFolder<I> for Canonicalizer<'_, D, I>

impl<D: SolverDelegate<Interner = I>, I: Interner> TypeFolder<I> for EagerResolver<'_, D>

impl<D: SolverDelegate<Interner = I>, I: Interner> TypeFolder<I> for ReplaceProjectionWith<'_, D, I>

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for TransformTy<'tcx>

impl<'a, 'b, 'tcx> TypeFolder<TyCtxt<'tcx>> for AssocTypeNormalizer<'a, 'b, 'tcx>

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ClosureEraser<'tcx>

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReplaceImplTraitFolder<'tcx>

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for DeeplyNormalizeForDiagnosticsFolder<'_, 'tcx>

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for EraseEscapingBoundRegions<'tcx>

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for BoundVarReplacer<'_, 'tcx>

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for PlaceholderReplacer<'_, 'tcx>