Module infer
Expand description
Infer context the next-trait-solver.
Modules§
- at
- A nice interface for working with the infcx. The basic idea is to
do
infcx.at(cause, param_env), which sets the “cause” of the operation as well as the surrounding parameter environment. Then you can do something like.sub(a, b)or.eq(a, b)to create a subtype or equality relationship respectively. The first argument is always the “expected” output from the POV of diagnostics. - canonical
- Canonicalization is the key to constructing a query in the
middle of type inference. Ordinarily, it is not possible to store
types from type inference in query keys, because they contain
references to inference variables whose lifetimes are too short
and so forth. Canonicalizing a value T1 using
canonicalize_queryproduces two things: - opaque_
types - Things related to the infer context of the next-trait-solver.
- region_
constraints - See
README.md. - relate
- This module contains the definitions of most
TypeRelations in the type system (except for some relations used for diagnostics and heuristics in the compiler). As well as the implementation ofRelatefor interned things (Ty/Const/etc). - resolve
- Things for resolving vars in the infer context of the next-trait-solver.
Structs§
- Fixup
Error - Infer
Ctxt - Infer
Ctxt Builder - Used to configure inference contexts before their creation.
- Infer
Ctxt Inner - This type contains all the things within
InferCtxtthat sit within aRefCelland are involved with taking/rolling back snapshots. Snapshot operations are hot enough that we want only one call toborrow_mutper call tostart_snapshotandrollback_to. - InferOk
InferOk<'db, ()>is used a lot. It may seem like a useless wrapper aroundPredicateObligations, but it has one important property: becauseInferOkis marked with#[must_use], if you have a methodInferCtxt::fthat returnsInferResult<()>and you call it withinfcx.f()?;you’ll get a warning about the obligations being discarded without use, which is probably unintentional and has been a source of bugs in the past.- Member
Constraint - Requires that
regionmust be equal to one of the regions inchoice_regions. We often denote this using the syntax: - Type
Outlives Constraint - See the
region_obligationsfield for more information. - Type
Trace - The trace designates the path through inference that we took to encounter an error or subtyping constraint.
Enums§
- Bound
Region Conversion Time - Times when we replace bound regions with existentials:
- TyOr
Const Infer Var - Helper for InferCtxt::ty_or_const_infer_var_changed (see comment on that), currently
used only for
traits::fulfill’s list ofstalled_oninference variables. - Value
Pairs - See the
error_reportingmodule for more details.