Module chalk_ir::fold

source ·
Expand description

Traits for transforming bits of IR.

Re-exports

pub use self::shift::Shift;

Modules

This module contains impls of TypeFoldable for those types that introduce binders.
This module contains “rote and uninteresting” impls of TypeFoldable for various types. In general, we prefer to derive TypeFoldable, but sometimes that doesn’t work for whatever reason.
in_place 🔒
Subroutines to help implementers of TypeFoldable avoid unnecessary heap allocations.
Shifting of debruijn indices
subst 🔒

Structs

Substitution used during folding

Traits

A “folder” is a transformer that can be used to make a copy of some term – that is, some bit of IR, such as a Goal – with certain changes applied. The idea is that it contains methods that let you swap types/lifetimes for new types/lifetimes; meanwhile, each bit of IR implements the TypeFoldable trait which, given a FallibleTypeFolder, will reconstruct itself, invoking the folder’s methods to transform each of the types/lifetimes embedded within.
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).
A “folder” is a transformer that can be used to make a copy of some term – that is, some bit of IR, such as a Goal – with certain changes applied. The idea is that it contains methods that let you swap types/lifetimes for new types/lifetimes; meanwhile, each bit of IR implements the TypeFoldable trait which, given a TypeFolder, will reconstruct itself, invoking the folder’s methods to transform each of the types/lifetimes embedded within.
For types where “fold” invokes a callback on the TypeFolder, the TypeSuperFoldable trait captures the recursive behavior that folds all the contents of the type.