struct Unifier<'t, I: Interner> {
    table: &'t mut InferenceTable<I>,
    environment: &'t Environment<I>,
    goals: Vec<InEnvironment<Goal<I>>>,
    interner: I,
    db: &'t dyn UnificationDatabase<I>,
}

Fields§

§table: &'t mut InferenceTable<I>§environment: &'t Environment<I>§goals: Vec<InEnvironment<Goal<I>>>§interner: I§db: &'t dyn UnificationDatabase<I>

Implementations§

source§

impl<'t, I: Interner> Unifier<'t, I>

source

fn new( interner: I, db: &'t dyn UnificationDatabase<I>, table: &'t mut InferenceTable<I>, environment: &'t Environment<I> ) -> Self

source

fn relate<T>( self, variance: Variance, a: &T, b: &T ) -> Fallible<RelationResult<I>>
where T: ?Sized + Zip<I>,

The main entry point for the Unifier type and really the only type meant to be called externally. Performs a relation of a and b and returns the Unification Result.

source

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

Relate a, b with the variance such that if variance = Covariant, a is a subtype of b.

source

fn unify_var_var(&mut self, a: InferenceVar, b: InferenceVar) -> Fallible<()>

Unify two inference variables

source

fn unify_general_var_specific_ty( &mut self, general_var: InferenceVar, specific_ty: Ty<I> ) -> Fallible<()>

Unify a general inference variable with a specific inference variable (type kind is not General). For example, unify a TyVariableKind::General inference variable with a TyVariableKind::Integer variable, resulting in the general inference variable narrowing to an integer variable.

source

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

source

fn relate_alias_ty( &mut self, variance: Variance, alias: &AliasTy<I>, ty: &Ty<I> ) -> Fallible<()>

Relate an alias like <T as Trait>::Item or impl Trait with some other type ty. If the variance is Invariant, creates a goal like

AliasEq(<T as Trait>::Item = U) // associated type projection
AliasEq(impl Trait = U) // impl trait

Otherwise, this creates a new variable ?X, creates a goal like

AliasEq(Alias = ?X)

and relates ?X and ty.

source

fn generalize_ty( &mut self, ty: &Ty<I>, universe_index: UniverseIndex, variance: Variance ) -> Ty<I>

source

fn generalize_lifetime( &mut self, lifetime: &Lifetime<I>, universe_index: UniverseIndex, variance: Variance ) -> Lifetime<I>

source

fn generalize_const( &mut self, const_: &Const<I>, universe_index: UniverseIndex ) -> Const<I>

source

fn generalize_generic_var( &mut self, sub_var: &GenericArg<I>, universe_index: UniverseIndex, variance: Variance ) -> GenericArg<I>

source

fn generalize_substitution_skip_self<F: Fn(usize) -> Option<Variance>>( &mut self, substitution: &Substitution<I>, universe_index: UniverseIndex, get_variance: F ) -> Substitution<I>

Generalizes all but the first

source

fn generalize_substitution<F: Fn(usize) -> Variance>( &mut self, substitution: &Substitution<I>, universe_index: UniverseIndex, get_variance: F ) -> Substitution<I>

source

fn relate_var_ty( &mut self, variance: Variance, var: InferenceVar, var_kind: TyVariableKind, ty: &Ty<I> ) -> Fallible<()>

Unify an inference variable var with some non-inference variable ty, just bind var to ty. But we must enforce two conditions:

  • var does not appear inside of ty (the standard OccursCheck)
  • ty does not reference anything in a lifetime that could not be named in var (the extended OccursCheck created to handle universes)
source

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

source

fn unify_lifetime_var( &mut self, variance: Variance, var: InferenceVar, value: &Lifetime<I>, value_ui: UniverseIndex ) -> Fallible<()>

source

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

source

fn unify_var_const(&mut self, var: InferenceVar, c: &Const<I>) -> Fallible<()>

source

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

Relate a, b such that if variance = Covariant, a is a subtype of b and thus a must outlive b.

source

fn push_subtype_goal(&mut self, a: Ty<I>, b: Ty<I>)

Pushes a goal of a being a subtype of b.

Trait Implementations§

source§

impl<'i, I: Interner> Zipper<I> for Unifier<'i, I>

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
source§

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

Zips two substs

Auto Trait Implementations§

§

impl<'t, I> !RefUnwindSafe for Unifier<'t, I>

§

impl<'t, I> !Send for Unifier<'t, I>

§

impl<'t, I> !Sync for Unifier<'t, I>

§

impl<'t, I> Unpin for Unifier<'t, I>

§

impl<'t, I> !UnwindSafe for Unifier<'t, I>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> Cast for T

source§

fn cast<U>(self, interner: <U as HasInterner>::Interner) -> U
where Self: CastTo<U>, U: HasInterner,

Cast a value to type U using CastTo.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more