Module rustc_infer::infer::relate::combine
source · Expand description
There are four type combiners: TypeRelating, Lub, and Glb,
and NllTypeRelating
in rustc_borrowck, which is only used for NLL.
Each implements the trait TypeRelation and contains methods for
combining two instances of various things and yielding a new instance.
These combiner methods always yield a Result<T>
. To relate two
types, you can use infcx.at(cause, param_env)
which then allows
you to use the relevant methods of At.
Combiners mostly do their specific behavior and then hand off the bulk of the work to InferCtxt::super_combine_tys and InferCtxt::super_combine_consts.
Combining two types may have side-effects on the inference contexts which can be undone by using snapshots. You probably want to use either InferCtxt::commit_if_ok or InferCtxt::probe.
On success, the LUB/GLB operations return the appropriate bound. The
return value of Equate
or Sub
shouldn’t really be used.
Structs§
Enums§
- Extra information about why we ended up with a particular variance. This is only used to add more information to error messages, and has no effect on soundness. While choosing the ‘wrong’
VarianceDiagInfo
may lead to confusing notes in error messages, it will never cause a miscompilation or unsoundness.
Traits§
Functions§
- Relates
a
andb
structurally, calling the relation for all nested values. Any semantic equality, e.g. of unevaluated consts, and inference variables have to be handled by the caller. - Relates
a
andb
structurally, calling the relation for all nested values. Any semantic equality, e.g. of projections, and inference variables have to be handled by the caller.