Struct rustc::middle::ty_match::MatchUnstable [-] [+] [src]

pub struct Match<'a, 'tcx> {
    // some fields omitted
}

A type "A" matches "B" if the fresh types in B could be substituted with values so as to make it equal to A. Matching is intended to be used only on freshened types, and it basically indicates if the non-freshened versions of A and B could have been unified.

It is only an approximation. If it yields false, unification would definitely fail, but a true result doesn't mean unification would succeed. This is because we don't track the "side-constraints" on type variables, nor do we track if the same freshened type appears more than once. To some extent these approximations could be fixed, given effort.

Like subtyping, matching is really a binary relation, so the only important thing about the result is Ok/Err. Also, matching never affects any type variables or unification state.

Methods

impl<'a, 'tcx> Match<'a, 'tcx>

fn new(tcx: &'a ctxt<'tcx>) -> Match<'a, 'tcx>

Trait Implementations

impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Match<'a, 'tcx>

fn tag(&self) -> &'static str

fn tcx(&self) -> &'a ctxt<'tcx>

fn a_is_expected(&self) -> bool

fn relate_with_variance<T: Relate<'a, 'tcx>>(&mut self, _: Variance, a: &T, b: &T) -> RelateResult<'tcx, T>

fn regions(&mut self, a: Region, b: Region) -> RelateResult<'tcx, Region>

fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>>

fn binders<T>(&mut self, a: &Binder<T>, b: &Binder<T>) -> RelateResult<'tcx, Binder<T>> where T: Relate<'a, 'tcx>

fn relate<T: Relate<'a, 'tcx>>(&mut self, a: &T, b: &T) -> RelateResult<'tcx, T>