Module rustc::traits [] [src]

Unstable (rustc_private)

Trait Resolution. See the Book for more.

Reexports

pub use self::SelectionError::*;
pub use self::FulfillmentErrorCode::*;
pub use self::Vtable::*;
pub use self::ObligationCauseCode::*;
pub use self::select::{MethodMatched, MethodAmbiguous, MethodDidNotMatch};

Modules

specialization_graph [Unstable]

Structs

DerivedObligationCause [Unstable]
EvaluationCache [Unstable]
FulfillmentContext [Unstable]

The fulfillment context is used to drive trait resolution. It consists of a list of obligations that must be (eventually) satisfied. The job is to track which are satisfied, which yielded errors, and which are still pending. At any point, users can call select_where_possible, and the fulfilment context will try to do selection, retaining only those obligations that remain ambiguous. This may be helpful in pushing type inference along. Once all type inference constraints have been generated, the method select_all_or_error can be used to report any remaining ambiguous cases as errors.

FulfillmentError [Unstable]
GlobalFulfilledPredicates [Unstable]
MismatchedProjectionTypes [Unstable]
Normalized [Unstable]
Obligation [Unstable]

An Obligation represents some trait reference (e.g. int:Eq) for which the vtable must be found. The process of finding a vtable is called "resolving" the Obligation. This process consists of either identifying an impl (e.g., impl Eq for int) that provides the required vtable, or else finding a bound that is in scope. The eventual result is usually a Selection (defined below).

ObligationCause [Unstable]

Why did we incur this obligation? Used for error reporting.

OverlapError [Unstable]

Information pertinent to an overlapping impl error.

RegionObligation [Unstable]
SelectionCache [Unstable]
SelectionContext [Unstable]
SpecializesCache [Unstable]
SupertraitDefIds [Unstable]
TraitErrorKey [Unstable]
VtableBuiltinData [Unstable]
VtableClosureData [Unstable]
VtableDefaultImplData [Unstable]
VtableFnPointerData [Unstable]
VtableImplData [Unstable]

Identifies a particular impl in the source, along with a set of substitutions from the impl's type/lifetime parameters. The nested vector corresponds to the nested obligations attached to the impl's type parameters.

VtableObjectData [Unstable]

A vtable for some object-safe trait Foo automatically derived for the object type Foo.

Enums

FulfillmentErrorCode [Unstable]
MethodMatchResult [Unstable]
MethodMatchedData [Unstable]
MethodViolationCode [Unstable]

Reasons a method might not be object-safe.

ObjectSafetyViolation [Unstable]
ObligationCauseCode [Unstable]
OrphanCheckErr [Unstable]
ProjectionMode [Unstable]

Depending on the stage of compilation, we want projection to be more or less conservative.

SelectionError [Unstable]
Vtable [Unstable]

Given the successful resolution of an obligation, the Vtable indicates where the vtable comes from. Note that while we call this a "vtable", it does not necessarily indicate dynamic dispatch at runtime. Vtable instances just tell the compiler where to find methods, but in generic code those methods are typically statically dispatched -- only when an object is constructed is a Vtable instance reified into an actual vtable.

Functions

elaborate_predicates [Unstable]
fully_normalize [Unstable]
normalize [Unstable]

Normalizes any associated type projections in value, replacing them with a fully resolved type where possible. The return value combines the normalized result and any additional obligations that were incurred as result.

normalize_param_env_or_error [Unstable]

Normalizes the parameter environment, reporting errors if they occur.

orphan_check [Unstable]

Checks the coherence orphan rules. impl_def_id should be the def-id of a trait impl. To pass, either the trait must be local, or else two conditions must be satisfied:

overlapping_impls [Unstable]

If there are types that satisfy both impls, returns a suitably-freshened ImplHeader with those types substituted

predicates_for_generics [Unstable]

Creates predicate obligations from the generic bounds.

specializes [Unstable]

Is impl1 a specialization of impl2?

supertrait_def_ids [Unstable]
supertraits [Unstable]
transitive_bounds [Unstable]
translate_substs [Unstable]

Given a subst for the requested impl, translate it to a subst appropriate for the actual item definition (whether it be in that impl, a parent impl, or the trait). When we have selected one impl, but are actually using item definitions from a parent impl providing a default, we need a way to translate between the type parameters of the two impls. Here the source_impl is the one we've selected, and source_substs is a substitution of its generics (and possibly some relevant FnSpace variables as well). And target_node is the impl/trait we're actually going to get the definition from. The resulting substitution will map from target_node's generics to source_impl's generics as instantiated by source_subst.

type_known_to_meet_builtin_bound [Unstable]

Determines whether the type ty is known to meet bound and returns true if so. Returns false if ty either does not meet bound or is not known to meet bound (note that this is conservative towards no impl, which is the opposite of the evaluate methods).

Type Definitions

Obligations [Unstable]
PredicateObligation [Unstable]
PredicateObligations [Unstable]
Selection [Unstable]
SelectionResult [Unstable]

When performing resolution, it is typically the case that there can be one of three outcomes:

Supertraits [Unstable]
TraitObligation [Unstable]
TraitObligations [Unstable]