Trait rustc_infer::infer::nll_relate::VidValuePair
source · trait VidValuePair<'tcx>: Debug {
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
Extract the inference variable (which could be either the first or second part of the tuple).
Extract the value it is being related to (which will be the opposite part of the tuple from the vid).
sourcefn vid_scopes<'r, D: TypeRelatingDelegate<'tcx>>(
&self,
relate: &'r mut TypeRelating<'_, 'tcx, D>
) -> &'r mut Vec<BoundRegionScope<'tcx>>
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.
sourcefn relate_generalized_ty<D>(
&self,
relate: &mut TypeRelating<'_, 'tcx, D>,
generalized_ty: Ty<'tcx>
) -> RelateResult<'tcx, Ty<'tcx>>where
D: TypeRelatingDelegate<'tcx>,
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.