trait VidValuePair<'tcx>: Debug {
    // Required methods
    fn vid(&self) -> TyVid;
    fn value_ty(&self) -> Ty<'tcx>;
    fn vid_scopes<'r, D: TypeRelatingDelegate<'tcx>>(
        &self,
        relate: &'r mut TypeRelating<'_, 'tcx, D>
    ) -> &'r mut Vec<BoundRegionScope<'tcx>>;
    fn relate_generalized_ty<D>(
        &self,
        relate: &mut TypeRelating<'_, 'tcx, D>,
        generalized_ty: Ty<'tcx>
    ) -> RelateResult<'tcx, Ty<'tcx>>
       where D: TypeRelatingDelegate<'tcx>;
}
Expand description

When we instantiate an inference variable with a value in relate_ty_var, we always have the pair of a TyVid and a Ty, but the ordering may vary (depending on whether the inference variable was found on the a or b sides). Therefore, this trait allows us to factor out common code, while preserving the order when needed.

Required Methods§

source

fn vid(&self) -> TyVid

Extract the inference variable (which could be either the first or second part of the tuple).

source

fn value_ty(&self) -> Ty<'tcx>

Extract the value it is being related to (which will be the opposite part of the tuple from the vid).

source

fn vid_scopes<'r, D: TypeRelatingDelegate<'tcx>>( &self, relate: &'r mut TypeRelating<'_, 'tcx, D> ) -> &'r mut Vec<BoundRegionScope<'tcx>>

Extract the scopes that apply to whichever side of the tuple the vid was found on. See the comment where this is called for more details on why we want them.

source

fn relate_generalized_ty<D>( &self, relate: &mut TypeRelating<'_, 'tcx, D>, generalized_ty: Ty<'tcx> ) -> RelateResult<'tcx, Ty<'tcx>>where D: TypeRelatingDelegate<'tcx>,

Given a generalized type G that should replace the vid, relate G to the value, putting G on whichever side the vid would have appeared.

Implementations on Foreign Types§

source§

impl<'tcx> VidValuePair<'tcx> for (TyVid, Ty<'tcx>)

source§

fn vid(&self) -> TyVid

source§

fn value_ty(&self) -> Ty<'tcx>

source§

fn vid_scopes<'r, D>( &self, relate: &'r mut TypeRelating<'_, 'tcx, D> ) -> &'r mut Vec<BoundRegionScope<'tcx>>where D: TypeRelatingDelegate<'tcx>,

source§

fn relate_generalized_ty<D>( &self, relate: &mut TypeRelating<'_, 'tcx, D>, generalized_ty: Ty<'tcx> ) -> RelateResult<'tcx, Ty<'tcx>>where D: TypeRelatingDelegate<'tcx>,

source§

impl<'tcx> VidValuePair<'tcx> for (Ty<'tcx>, TyVid)

source§

fn vid(&self) -> TyVid

source§

fn value_ty(&self) -> Ty<'tcx>

source§

fn vid_scopes<'r, D>( &self, relate: &'r mut TypeRelating<'_, 'tcx, D> ) -> &'r mut Vec<BoundRegionScope<'tcx>>where D: TypeRelatingDelegate<'tcx>,

source§

fn relate_generalized_ty<D>( &self, relate: &mut TypeRelating<'_, 'tcx, D>, generalized_ty: Ty<'tcx> ) -> RelateResult<'tcx, Ty<'tcx>>where D: TypeRelatingDelegate<'tcx>,

Implementors§