Skip to main content

Module project

Module project 

Source
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Β§

ProjectAndUnifyResult πŸ”’
States returned from poly_project_and_unify_type. Takes the place of the old return type, which was:
Projected πŸ”’
ProjectionCandidate πŸ”’
ProjectionCandidateSet πŸ”’
ProjectionError
When attempting to resolve <T as TraitRef>::Name …

TraitsΒ§

ProjectionCacheKeyExt πŸ”’

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>::Item we 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 of Foo has 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 given goal_kind and env_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 $X and generate a new obligation <T as Trait>::Item == $X for later.
normalize_to_error πŸ”’
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.
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). Returns None in 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 ConstArgHasType obligation to ensure the const value’s type matches the declared type.

Type AliasesΒ§

PolyProjectionObligation
ProjectionObligation
ProjectionTermObligation