Module rustc_typeck::middle::traits [−] [src]

Unstable

Trait Resolution. See the Book for more.

Structs

DerivedObligationCause [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]
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.

RegionObligation [Unstable]
SelectionCache [Unstable]
SelectionContext [Unstable]
SupertraitDefIds [Unstable]
VtableBuiltinData [Unstable]
VtableDefaultImplData [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]
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]
evaluate_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).

fully_normalize [Unstable]
get_vtable_index_of_object_method [Unstable]

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 [Unstable]
is_vtable_safe_method [Unstable]

We say a method is vtable safe if it can be invoked on a trait object. Note that object-safe traits can have some non-vtable-safe methods, so long as they require Self:Sized or otherwise ensure that they cannot be used when Self=Trait.

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.

object_safety_violations [Unstable]
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]

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

predicate_for_trait_def [Unstable]
predicates_for_generics [Unstable]

Creates predicate obligations from the generic bounds.

report_fulfillment_errors [Unstable]
report_overflow_error [Unstable]

Reports that an overflow has occurred and halts compilation. We halt compilation unconditionally because it is important that overflows never be masked -- they basically represent computations whose result could not be truly determined and thus we can't say if the program type checks or not -- and they are unusual occurrences in any case.

report_selection_error [Unstable]
suggest_new_overflow_limit [Unstable]
supertrait_def_ids [Unstable]
supertraits [Unstable]
trait_ref_for_builtin_bound [Unstable]
transitive_bounds [Unstable]
type_known_to_meet_builtin_bound [Unstable]
upcast [Unstable]

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 [Unstable]
PredicateObligation [Unstable]
PredicateObligations [Unstable]
Selection [Unstable]
SelectionResult [Unstable]
Supertraits [Unstable]
TraitObligation [Unstable]
TraitObligations [Unstable]