pub struct TypeUnificationAdapter { /* private fields */ }
Expand description

Helper to unify types which stem from different generic contexts.

Both comparison side may have type parameters (equally named as #0, #1, …). The helper converts the type parameter from or both sides into variables and then performs unification of the terms. The resulting substitution is converted back to parameter instantiations.

Example: consider a function f which uses memory M<X, u64>, and invariant invariant which uses memory M<bool, X>. Using this helper to unify both memories will result in instantiations which when applied create f and invariant respectively.

Implementations§

source§

impl TypeUnificationAdapter

source

pub fn new_pair( lhs_type: &Type, rhs_type: &Type, treat_lhs_type_param_as_var: bool, treat_rhs_type_param_as_var: bool ) -> Self

Create a TypeUnificationAdapter with the goal of unifying a pair of types.

If treat_lhs_type_param_as_var is True, treat all type parameters on the LHS as variables. If treat_rhs_type_param_as_var is True, treat all type parameters on the RHS as variables.

source

pub fn new_vec( lhs_types: &[Type], rhs_types: &[Type], treat_lhs_type_param_as_var: bool, treat_rhs_type_param_as_var: bool ) -> Self

Create a TypeUnificationAdapter with the goal of unifying a pair of type tuples.

If treat_lhs_type_param_as_var is True, treat all type parameters on the LHS as variables. If treat_rhs_type_param_as_var is True, treat all type parameters on the RHS as variables.

source

pub fn unify( self, variance: Variance, shallow_subst: bool ) -> Option<(BTreeMap<u16, Type>, BTreeMap<u16, Type>)>

Consume the TypeUnificationAdapter and produce the unification result. If type unification is successful, return a pair of instantiations for type parameters on each side which unify the LHS and RHS respectively. If the LHS and RHS cannot unify, None is returned.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V