Module rustc::traits::project[][src]

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Code for projecting associated types out of trait references.

Re-exports

use super::elaborate_predicates;
use super::specialization_graph;
use super::translate_substs;
use super::Obligation;
use super::ObligationCause;
use super::PredicateObligation;
use super::Selection;
use super::SelectionContext;
use super::SelectionError;
use super::VtableClosureData;
use super::VtableGeneratorData;
use super::VtableFnPointerData;
use super::VtableImplData;
use super::util;
use hir::def_id::DefId;
use infer::InferCtxt;
use infer::InferOk;
use infer::type_variable::TypeVariableOrigin;
use middle::const_val::ConstVal;
use mir::interpret::GlobalId;
use rustc_data_structures::snapshot_map::Snapshot;
use rustc_data_structures::snapshot_map::SnapshotMap;
use syntax::symbol::Symbol;
use ty::subst::Subst;
use ty::subst::Substs;
use ty;
use ty::ToPredicate;
use ty::ToPolyTraitRef;
use ty::Ty;
use ty::TyCtxt;
use ty::fold::TypeFoldable;
use ty::fold::TypeFolder;
use util::common::FN_OUTPUT_NAME;

Structs

AssociatedTypeNormalizer [
Experimental
]
MismatchedProjectionTypes [
Experimental
]
Normalized [
Experimental
]
Progress [
Experimental
]
ProjectionCache [
Experimental
]

The projection cache. Unlike the standard caches, this can include infcx-dependent type variables - therefore, we have to roll the cache back each time we roll a snapshot back, to avoid assumptions on yet-unresolved inference variables. Types with skolemized regions also have to be removed when the respective snapshot ends.

ProjectionCacheKey [
Experimental
]
ProjectionCacheSnapshot [
Experimental
]

Enums

ProjectedTy [
Experimental
]
ProjectionCacheEntry [
Experimental
]
ProjectionTyCandidate [
Experimental
]
ProjectionTyCandidateSet [
Experimental
]
ProjectionTyError [
Experimental
]

When attempting to resolve <T as TraitRef>::Name ...

Reveal [
Experimental
]

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

Functions

assemble_candidates_from_impls [
Experimental
]
assemble_candidates_from_param_env [
Experimental
]

The first thing we have to do is scan through the parameter environment to see whether there are any projection predicates there that can answer this question.

assemble_candidates_from_predicates [
Experimental
]
assemble_candidates_from_trait_def [
Experimental
]

In the case of a nested projection like <::FooT as Bar>::BarT, we may find that the definition of Foo has some clues:

assoc_ty_def [
Experimental
]

Locate the definition of an associated type in the specialization hierarchy, starting from the given impl.

confirm_callable_candidate [
Experimental
]
confirm_candidate [
Experimental
]
confirm_closure_candidate [
Experimental
]
confirm_fn_pointer_candidate [
Experimental
]
confirm_generator_candidate [
Experimental
]
confirm_impl_candidate [
Experimental
]
confirm_object_candidate [
Experimental
]
confirm_param_env_candidate [
Experimental
]
confirm_select_candidate [
Experimental
]
normalize [
Experimental
]

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_projection_type [
Experimental
]

The guts of normalize: normalize a specific projection like <T as Trait>::Item. The result is always a type (and possibly additional obligations). If ambiguity arises, which implies that there are unresolved type variables in the projection, we will substitute a fresh type variable $X and generate a new obligation <T as Trait>::Item == $X for later.

normalize_to_error [
Experimental
]

If we are projecting <T as Trait>::Item, but T: Trait does not hold. In various error cases, we cannot generate a valid normalized projection. Therefore, we create an inference variable return an associated obligation that, when fulfilled, will lead to an error.

normalize_with_depth [
Experimental
]

As normalize, but with a custom depth.

opt_normalize_projection_type [
Experimental
]

The guts of normalize: normalize a specific projection like <T as Trait>::Item. The result is always a type (and possibly additional obligations). Returns None in the case of ambiguity, which indicates that there are unbound type variables.

poly_project_and_unify_type [
Experimental
]

Evaluates constraints of the form:

project_and_unify_type [
Experimental
]

Evaluates constraints of the form:

project_type [
Experimental
]

Compute the result of a projection type (if we can).

prune_cache_value_obligations [
Experimental
]

If there are unresolved type variables, then we need to include any subobligations that bind them, at least until those type variables are fully resolved.

push_paranoid_cache_value_obligation [
Experimental
]

Whenever we give back a cache result for a projection like <T as Trait>::Item ==> X, we always include the obligation to prove that T: Trait (we may also include some other obligations). This may or may not be necessary -- in principle, all the obligations that must be proven to show that T: Trait were also returned when the cache was first populated. But there are some vague concerns, and so we take the precatuionary measure of including T: Trait in the result:

Type Definitions

NormalizedTy [
Experimental
]
PolyProjectionObligation [
Experimental
]
ProjectionObligation [
Experimental
]
ProjectionTyObligation [
Experimental
]