Trait chalk_ir::zip::Zipper

source ·
pub trait Zipper<I: Interner> {
    // Required methods
    fn zip_tys(
        &mut self,
        variance: Variance,
        a: &Ty<I>,
        b: &Ty<I>,
    ) -> Fallible<()>;
    fn zip_lifetimes(
        &mut self,
        variance: Variance,
        a: &Lifetime<I>,
        b: &Lifetime<I>,
    ) -> Fallible<()>;
    fn zip_consts(
        &mut self,
        variance: Variance,
        a: &Const<I>,
        b: &Const<I>,
    ) -> Fallible<()>;
    fn zip_binders<T>(
        &mut self,
        variance: Variance,
        a: &Binders<T>,
        b: &Binders<T>,
    ) -> Fallible<()>
       where T: Clone + HasInterner<Interner = I> + Zip<I> + TypeFoldable<I>;
    fn interner(&self) -> I;
    fn unification_database(&self) -> &dyn UnificationDatabase<I>;

    // Provided method
    fn zip_substs(
        &mut self,
        ambient: Variance,
        variances: Option<Variances<I>>,
        a: &[GenericArg<I>],
        b: &[GenericArg<I>],
    ) -> Fallible<()>
       where Self: Sized { ... }
}
Expand description

When we zip types, we basically traverse the structure, ensuring that it matches. When we come to types/lifetimes, we invoke the callback methods in the zipper to match them up. Primarily used during unification or similar operations.

So e.g. if you had A: Eq<B> zipped with X: Eq<Y>, then the zipper would get two callbacks, one pairing A and X, and the other pairing B and Y.

For things other than types/lifetimes, the zip impls will guarantee equality. So e.g. if you have A: Eq<B> zipped with X: Ord<Y>, you would wind up with an error, no matter what zipper you are using. This is because the traits Eq and Ord are represented by two distinct ItemId values, and the impl for ItemId requires that all ItemId in the two zipped values match up.

Required Methods§

source

fn zip_tys(&mut self, variance: Variance, a: &Ty<I>, b: &Ty<I>) -> Fallible<()>

Indicates that the two types a and b were found in matching spots.

source

fn zip_lifetimes( &mut self, variance: Variance, a: &Lifetime<I>, b: &Lifetime<I>, ) -> Fallible<()>

Indicates that the two lifetimes a and b were found in matching spots.

source

fn zip_consts( &mut self, variance: Variance, a: &Const<I>, b: &Const<I>, ) -> Fallible<()>

Indicates that the two consts a and b were found in matching spots.

source

fn zip_binders<T>( &mut self, variance: Variance, a: &Binders<T>, b: &Binders<T>, ) -> Fallible<()>
where T: Clone + HasInterner<Interner = I> + Zip<I> + TypeFoldable<I>,

Zips two values appearing beneath binders.

source

fn interner(&self) -> I

Retrieves the interner from the underlying zipper object

source

fn unification_database(&self) -> &dyn UnificationDatabase<I>

Retrieves the UnificationDatabase from the underlying zipper object

Provided Methods§

source

fn zip_substs( &mut self, ambient: Variance, variances: Option<Variances<I>>, a: &[GenericArg<I>], b: &[GenericArg<I>], ) -> Fallible<()>
where Self: Sized,

Zips two substs

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'f, Z, I> Zipper<I> for &'f mut Z
where I: Interner, Z: Zipper<I>,

source§

fn zip_tys(&mut self, variance: Variance, a: &Ty<I>, b: &Ty<I>) -> Fallible<()>

source§

fn zip_lifetimes( &mut self, variance: Variance, a: &Lifetime<I>, b: &Lifetime<I>, ) -> Fallible<()>

source§

fn zip_consts( &mut self, variance: Variance, a: &Const<I>, b: &Const<I>, ) -> Fallible<()>

source§

fn zip_binders<T>( &mut self, variance: Variance, a: &Binders<T>, b: &Binders<T>, ) -> Fallible<()>
where T: Clone + HasInterner<Interner = I> + Zip<I> + TypeFoldable<I>,

source§

fn interner(&self) -> I

source§

fn unification_database(&self) -> &dyn UnificationDatabase<I>

Implementors§