Module rustc::middle::traitsUnstable [-] [+] [src]

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};

Structs

DerivedObligationCause
FulfillmentContext

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
MismatchedProjectionTypes
Normalized
Obligation

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

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

RegionObligation
SelectionCache
SelectionContext
Supertraits

A filter around the Elaborator that just yields up supertrait references, not other kinds of predicates.

VtableBuiltinData
VtableImplData

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

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

Enums

FulfillmentErrorCode
MethodMatchResult
MethodMatchedData
MethodViolationCode

Reasons a method might not be object-safe.

ObjectSafetyViolation
ObligationCauseCode
OrphanCheckErr
SelectionError
Vtable

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
evaluate_builtin_bound

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).

fully_normalize
get_vtable_index_of_object_method

Given an object of type object_trait_ref, returns the index of the method n_method found in the trait trait_def_id (which should be a supertrait of object_trait_ref) within the vtable for object_trait_ref.

is_object_safe
normalize

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
normalize_param_env_or_error
object_safety_violations
orphan_check

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

True if there exist types that satisfy both of the two given impls.

predicates_for_generics

Creates predicate obligations from the generic bounds.

report_fulfillment_errors
suggest_new_overflow_limit
supertraits
trait_ref_for_builtin_bound
transitive_bounds
type_known_to_meet_builtin_bound
upcast

Cast a trait reference into a reference to one of its super traits; returns None if target_trait_def_id is not a supertrait.

Type Definitions

Obligations
PredicateObligation
PredicateObligations
Selection
SelectionResult

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

TraitObligation
TraitObligations