Skip to main content

Module traits

Module traits 

Source
Expand description

Trait Resolution. See the rustc-dev-guide for more information on how this works.

Re-exportsยง

use std::cmp; ๐Ÿ”’
use std::hash::Hash; ๐Ÿ”’
use std::hash::Hash; ๐Ÿ”’
use std::hash::Hasher; ๐Ÿ”’
use hir::def_id::LocalDefId; ๐Ÿ”’
use rustc_hir as hir; ๐Ÿ”’
use rustc_macros::TypeFoldable; ๐Ÿ”’
use rustc_macros::TypeVisitable; ๐Ÿ”’
use rustc_middle::traits::query::NoSolution; ๐Ÿ”’
use rustc_middle::traits::solve::Certainty; ๐Ÿ”’
use rustc_middle::ty; ๐Ÿ”’
use rustc_middle::ty::Ty; ๐Ÿ”’
use rustc_middle::ty::TyCtxt; ๐Ÿ”’
use rustc_middle::ty::Upcast; ๐Ÿ”’
use rustc_span::Span; ๐Ÿ”’
use thin_vec::ThinVec; ๐Ÿ”’
pub use self::engine::FromSolverError;
pub use self::engine::ScrubbedTraitError;
pub use self::engine::TraitEngine;
pub use self::engine::TraitErrors;
pub(crate) use self::project::UndoLog; ๐Ÿ”’
pub use self::project::MismatchedProjectionTypes;
pub use self::project::Normalized;
pub use self::project::NormalizedTerm;
pub use self::project::ProjectionCache;
pub use self::project::ProjectionCacheEntry;
pub use self::project::ProjectionCacheKey;
pub use self::project::ProjectionCacheStorage;
use crate::infer::InferCtxt; ๐Ÿ”’

Modulesยง

cache
Cache for candidate selection.
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ยง

DerivedCause
DerivedHostCause
ImplDerivedCause
ImplDerivedHostCause
ImplSourceUserDefinedData
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.
MatchExpressionArmCause
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โ€ the Obligation. This process consists of either identifying an impl (e.g., impl Eq for i32) that satisfies the obligation, or else finding a bound that is in scope. The eventual result is usually a Selection (defined below).
ObligationCause
The reason why we incurred this obligation; used for error reporting.
ObligationCauseCodeHandle
A compact form of ObligationCauseCode.
PatternOriginExpr
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.
SignatureMismatchData

Enumsยง

AssocConstViolation
Reasons an associated const might not be dyn compatible.
BuiltinImplSource
CodegenObligationError
These are the error cases for codegen_select_candidate.
DynCompatibilityViolation
DynCompatibilityViolationSolution
EvaluationResult
The result of trait evaluation. The order is important here as the evaluation of a list is the maximum of the evaluations.
ImplSource
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.
MethodViolation
Reasons a method might not be dyn-compatible.
ObligationCauseCode
OverflowError
Indicates that trait evaluation caused overflow and in which pass.
SelectionError
WellFormedLoc
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 in Option<Foo>).

Type Aliasesยง

EvaluationCache
ObligationInspector
A callback that can be provided to inspect_typeck. Invoked on evaluation of root obligations.
PolyTraitObligation
PredicateObligation
PredicateObligations
Selection
SelectionCache
SelectionResult
When performing resolution, it is typically the case that there can be one of three outcomes:
TraitObligation