Expand description
Code for projecting associated types out of trait references.
Re-exportsΒ§
use std::ops::ControlFlow;πuse rustc_attr_ir::lang_items::LangItem;πuse rustc_data_structures::sso::SsoHashSet;πuse rustc_errors::ErrorGuaranteed;πuse rustc_hir::def_id::DefId;πuse rustc_infer::infer::DefineOpaqueTypes;πuse rustc_infer::traits::ObligationCauseCode;πuse rustc_infer::traits::PredicateObligations;πuse rustc_middle::traits::select::OverflowError;πuse rustc_middle::traits::BuiltinImplSource;πuse rustc_middle::traits::ImplSource;πuse rustc_middle::traits::ImplSourceUserDefinedData;πuse rustc_middle::ty::fast_reject::DeepRejectCtxt;πuse rustc_middle::ty;πuse rustc_middle::ty::CallerBoundsIterator;πuse rustc_middle::ty::FieldInfo;πuse rustc_middle::ty::Term;πuse rustc_middle::ty::Ty;πuse rustc_middle::ty::TyCtxt;πuse rustc_middle::ty::TypeVisitableExt;πuse rustc_middle::ty::TypingMode;πuse rustc_middle::ty::Unnormalized;πuse rustc_middle::ty::Upcast;πuse rustc_span::bug;πuse rustc_span::span_bug;πuse rustc_span::sym;πuse tracing::debug;πuse tracing::instrument;πuse tracing::instrument;πuse super::MismatchedProjectionTypes;πuse super::Normalized;πuse super::NormalizedTerm;πuse super::Obligation;πuse super::ObligationCause;πuse super::PredicateObligation;πuse super::ProjectionCacheEntry;πuse super::ProjectionCacheKey;πuse super::Selection;πuse super::SelectionContext;πuse super::SelectionError;πuse super::specialization_graph;πuse super::translate_args;πuse super::util;πuse crate::diagnostics::InherentProjectionNormalizationOverflow;πuse crate::error_reporting::traits::report_dyn_incompatibility;πuse crate::infer::BoundRegionConversionTime;πuse crate::infer::InferOk;πuse crate::traits::normalize::normalize_with_depth;πuse crate::traits::normalize::normalize_with_depth_to;πuse crate::traits::query::evaluate_obligation::InferCtxtExt as _;πuse crate::traits::select::ProjectionMatchesProjection;π
StructsΒ§
- InProgress π
- Progress π
EnumsΒ§
- Project
AndUnify πResult - States returned from
poly_project_and_unify_type. Takes the place of the old return type, which was: - Projected π
- Projection
Candidate π - Projection
Candidate πSet - Projection
Error - When attempting to resolve
<T as TraitRef>::Nameβ¦
TraitsΒ§
FunctionsΒ§
- assemble_
candidates_ πfrom_ clauses - assemble_
candidates_ πfrom_ impls - assemble_
candidates_ πfrom_ object_ ty - In the case of a trait object like
<dyn Iterator<Item = ()> as Iterator>::Itemwe can use the existential predicate in the trait object. - assemble_
candidates_ πfrom_ param_ env - 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_ trait_ def - In the case of a nested projection like
<<A as Foo>::FooT as Bar>::BarT, we may find that the definition ofFoohas some clues: - assoc_
term_ πown_ obligations - compute_
inherent_ assoc_ term_ args - confirm_
async_ πclosure_ candidate - confirm_
async_ πfn_ kind_ helper_ candidate - confirm_
async_ πiterator_ candidate - confirm_
builtin_ πcandidate - confirm_
callable_ πcandidate - confirm_
candidate π - confirm_
closure_ πcandidate - confirm_
coroutine_ πcandidate - confirm_
fn_ πpointer_ candidate - confirm_
future_ πcandidate - confirm_
impl_ πcandidate - confirm_
iterator_ πcandidate - confirm_
param_ πenv_ candidate - confirm_
select_ πcandidate - const_
of_ item_ or_ delayed_ bug - The old solver does not support references to non-type-consts. Emit a delayed bug if there is a type system reference to a non type const, as this should have already errored elsewhere.
- coroutine_
closure_ πoutput_ coroutine - Given a
CoroutineClosure(def_id, args), interpret it as a closure, and return its output type for the givengoal_kindandenv_region. - normalize_
inherent_ projection - Confirm and normalize the given inherent projection.
- normalize_
projection_ term - 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 instantiate it with a fresh type variable$Xand generate a new obligation<T as Trait>::Item == $Xfor later. - normalize_
to_ πerror - If we are projecting
<T as Trait>::Item, butT: Traitdoes 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. - opt_
normalize_ πprojection_ term - The guts of
normalize: normalize a specific projection like<T as Trait>::Item. The result is always a type (and possibly additional obligations). ReturnsNonein the case of ambiguity, which indicates that there are unbound type variables. - poly_
project_ πand_ unify_ term - Evaluates constraints of the form:
- project π
- Computes the result of a projection type (if we can).
- project_
and_ πunify_ term - Evaluates constraints of the form:
- push_
const_ πarg_ has_ type_ obligation - When normalizing a const alias, register a
ConstArgHasTypeobligation to ensure the const valueβs type matches the declared type.