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§

Traits§

Functions§