Struct rustc_infer::infer::combine::CombineFields
source · pub struct CombineFields<'infcx, 'tcx> {
pub infcx: &'infcx InferCtxt<'infcx, 'tcx>,
pub trace: TypeTrace<'tcx>,
pub cause: Option<Cause>,
pub param_env: ParamEnv<'tcx>,
pub obligations: PredicateObligations<'tcx>,
pub define_opaque_types: bool,
}
Fields
infcx: &'infcx InferCtxt<'infcx, 'tcx>
trace: TypeTrace<'tcx>
cause: Option<Cause>
param_env: ParamEnv<'tcx>
obligations: PredicateObligations<'tcx>
define_opaque_types: bool
Whether we should define opaque types or just treat them opaquely. Currently only used to prevent predicate matching from matching anything against opaque types.
Implementations
sourceimpl<'infcx, 'tcx> CombineFields<'infcx, 'tcx>
impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx>
pub fn tcx(&self) -> TyCtxt<'tcx>
pub fn equate<'a>(&'a mut self, a_is_expected: bool) -> Equate<'a, 'infcx, 'tcx>
pub fn sub<'a>(&'a mut self, a_is_expected: bool) -> Sub<'a, 'infcx, 'tcx>
pub fn lub<'a>(&'a mut self, a_is_expected: bool) -> Lub<'a, 'infcx, 'tcx>
pub fn glb<'a>(&'a mut self, a_is_expected: bool) -> Glb<'a, 'infcx, 'tcx>
sourcepub fn instantiate(
&mut self,
a_ty: Ty<'tcx>,
dir: RelationDir,
b_vid: TyVid,
a_is_expected: bool
) -> RelateResult<'tcx, ()>
pub fn instantiate(
&mut self,
a_ty: Ty<'tcx>,
dir: RelationDir,
b_vid: TyVid,
a_is_expected: bool
) -> RelateResult<'tcx, ()>
Here, dir
is either EqTo
, SubtypeOf
, or SupertypeOf
.
The idea is that we should ensure that the type a_ty
is equal
to, a subtype of, or a supertype of (respectively) the type
to which b_vid
is bound.
Since b_vid
has not yet been instantiated with a type, we
will first instantiate b_vid
with a generalized version
of a_ty
. Generalization introduces other inference
variables wherever subtyping could occur.
sourcefn generalize(
&self,
ty: Ty<'tcx>,
for_vid: TyVid,
dir: RelationDir
) -> RelateResult<'tcx, Generalization<'tcx>>
fn generalize(
&self,
ty: Ty<'tcx>,
for_vid: TyVid,
dir: RelationDir
) -> RelateResult<'tcx, Generalization<'tcx>>
Attempts to generalize ty
for the type variable for_vid
.
This checks for cycle – that is, whether the type ty
references for_vid
. The dir
is the “direction” for which we
a performing the generalization (i.e., are we producing a type
that can be used as a supertype etc).
Preconditions:
for_vid
is a “root vid”
pub fn add_const_equate_obligation(
&mut self,
a_is_expected: bool,
a: Const<'tcx>,
b: Const<'tcx>
)
sourceimpl<'a, 'tcx> CombineFields<'a, 'tcx>
impl<'a, 'tcx> CombineFields<'a, 'tcx>
sourcepub fn higher_ranked_sub<T>(
&mut self,
sub: Binder<'tcx, T>,
sup: Binder<'tcx, T>,
sub_is_expected: bool
) -> RelateResult<'tcx, ()>where
T: Relate<'tcx>,
pub fn higher_ranked_sub<T>(
&mut self,
sub: Binder<'tcx, T>,
sup: Binder<'tcx, T>,
sub_is_expected: bool
) -> RelateResult<'tcx, ()>where
T: Relate<'tcx>,
Checks whether for<..> sub <: for<..> sup
holds.
For this to hold, all instantiations of the super type have to be a super type of at least one instantiation of the subtype.
This is implemented by first entering a new universe.
We then replace all bound variables in sup
with placeholders,
and all bound variables in sub
with inference vars.
We can then just relate the two resulting types as normal.
Note: this is a subtle algorithm. For a full explanation, please see the rustc dev guide
Trait Implementations
sourceimpl<'infcx, 'tcx> Clone for CombineFields<'infcx, 'tcx>
impl<'infcx, 'tcx> Clone for CombineFields<'infcx, 'tcx>
sourcefn clone(&self) -> CombineFields<'infcx, 'tcx>
fn clone(&self) -> CombineFields<'infcx, 'tcx>
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations
impl<'infcx, 'tcx> !RefUnwindSafe for CombineFields<'infcx, 'tcx>
impl<'infcx, 'tcx> !Send for CombineFields<'infcx, 'tcx>
impl<'infcx, 'tcx> !Sync for CombineFields<'infcx, 'tcx>
impl<'infcx, 'tcx> Unpin for CombineFields<'infcx, 'tcx>where
'tcx: 'infcx,
impl<'infcx, 'tcx> !UnwindSafe for CombineFields<'infcx, 'tcx>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
Layout
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 120 bytes