Module rustc_typeck::middle::traitsExperimental [-]  [+] [src]

Trait Resolution. See doc.rs.

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.

Enums

FulfillmentErrorCode
MethodMatchResult
MethodMatchedData
ObligationCauseCode
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
is_orphan_impl

True if neither the trait nor self type is local. Note that impl_def_id must refer to an impl of a trait, not an inherent impl.

normalize
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
supertraits
trait_ref_for_builtin_bound
transitive_bounds
type_known_to_meet_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).

Type Definitions

Obligations
PredicateObligation
PredicateObligations
Selection
SelectionResult
TraitObligation
TraitObligations