Expand description
Trait Resolution. See the rustc-dev-guide for more information on how this works.
Re-exports§
pub use self::ImplSource::*;
pub use self::SelectionError::*;
Modules§
- engine 🔒
- project 🔒
- Code for projecting associated types out of trait references.
- query
- Experimental types for the trait query interface. The methods
defined in this module are all based on canonicalization,
which makes a canonical query by replacing unbound inference
variables and regions, so that results can be reused more broadly.
The providers for the queries defined here can be found in
rustc_traits
. - select
- Candidate selection. See the rustc dev guide for more information on how this works.
- solve
- specialization_
graph - structural_
impls 🔒 - util
Structs§
- Derived
Cause - Derived
Host Cause - IfExpression
Cause - Impl
Derived Cause - Impl
Derived Host Cause - Impl
Source User Defined Data - Identifies a particular impl in the source, along with a set of
generic parameters from the impl’s type/lifetime parameters. The
nested
vector corresponds to the nested obligations attached to the impl’s type parameters. - Interned
Obligation Cause Code - Match
Expression ArmCause - Mismatched
Projection Types - Normalized
- Obligation
- An
Obligation
represents some trait reference (e.g.,i32: Eq
) for which the “impl_source” must be found. The process of finding an “impl_source” is called “resolving” theObligation
. This process consists of either identifying animpl
(e.g.,impl Eq for i32
) that satisfies the obligation, or else finding a bound that is in scope. The eventual result is usually aSelection
(defined below). - Obligation
Cause - The reason why we incurred this obligation; used for error reporting.
- Pattern
Origin Expr - Information about the origin expression of a pattern, relevant to diagnostics. Fields here refer to the scrutinee of a pattern. If the scrutinee isn’t given in the diagnostic, then this won’t exist.
- Projection
Cache - The projection cache. Unlike the standard caches, this can include infcx-dependent type variables, therefore we have to roll the cache back each time we roll a snapshot back, to avoid assumptions on yet-unresolved inference variables. Types with placeholder regions also have to be removed when the respective snapshot ends.
- Projection
Cache Key - Projection
Cache Storage - Signature
Mismatch Data - Unify
Receiver Context
Enums§
- Builtin
Impl Source - Codegen
Obligation Error - These are the error cases for
codegen_select_candidate
. - DynCompatibility
Violation - DynCompatibility
Violation Solution - Evaluation
Result - The result of trait evaluation. The order is important here as the evaluation of a list is the maximum of the evaluations.
- Impl
Source - Given the successful resolution of an obligation, the
ImplSource
indicates where the impl comes from. - IsConstable
- Whether a value can be extracted into a const. Used for diagnostics around array repeat expressions.
- Method
Violation Code - Reasons a method might not be dyn-compatible.
- Obligation
Cause Code - Overflow
Error - Indicates that trait evaluation caused overflow and in which pass.
- Projection
Cache Entry - Scrubbed
Trait Error - A trait error with most of its information removed. This is the error
returned by an
ObligationCtxt
by default, and suitable if you just want to see if a predicate holds, and don’t particularly care about the error itself (except for if it’s an ambiguity or true error). - Selection
Error - Statement
AsExpression - Well
Formed Loc - The ‘location’ at which we try to perform HIR-based wf checking.
This information is used to obtain an
hir::Ty
, which we can walk in order to obtain precise spans for any ‘nested’ types (e.g.Foo
inOption<Foo>
).
Traits§
Type Aliases§
- Evaluation
Cache - Normalized
Term - Obligation
Inspector - A callback that can be provided to
inspect_typeck
. Invoked on evaluation of root obligations. - Poly
Trait Obligation - Predicate
Obligation - Predicate
Obligations - Selection
- Selection
Cache - Selection
Result - When performing resolution, it is typically the case that there can be one of three outcomes:
- Trait
Obligation