[−][src]Struct rustc_trait_selection::traits::SelectionContext
Fields
infcx: &'cx InferCtxt<'cx, 'tcx>freshener: TypeFreshener<'cx, 'tcx>Freshener used specifically for entries on the obligation stack. This ensures that all entries on the stack at one time will have the same set of placeholder entries, which is important for checking for trait bounds that recursively require themselves.
intercrate: boolIf true, indicates that the evaluation should be conservative
and consider the possibility of types outside this crate.
This comes up primarily when resolving ambiguity. Imagine
there is some trait reference $0: Bar where $0 is an
inference variable. If intercrate is true, then we can never
say for sure that this reference is not implemented, even if
there are no impls at all for Bar, because $0 could be
bound to some type that in a downstream crate that implements
Bar. This is the suitable mode for coherence. Elsewhere,
though, we set this to false, because we are only interested
in types that the user could actually have written --- in
other words, we consider $0: Bar to be unimplemented if
there is no type that the user could actually name that
would satisfy it. This avoids crippling inference, basically.
intercrate_ambiguity_causes: Option<Vec<IntercrateAmbiguityCause>>allow_negative_impls: boolControls whether or not to filter out negative impls when selecting. This is used in librustdoc to distinguish between the lack of an impl and a negative impl
query_mode: TraitQueryModeThe mode that trait queries run in, which informs our error handling policy. In essence, canonicalized queries need their errors propagated rather than immediately reported because we do not have accurate spans.
Implementations
impl<'cx, 'tcx> SelectionContext<'cx, 'tcx>[src]
pub(in traits::select) fn candidate_from_obligation<'o>(
&mut self,
stack: &TraitObligationStack<'o, 'tcx>
) -> SelectionResult<'tcx, SelectionCandidate<'tcx>>[src]
&mut self,
stack: &TraitObligationStack<'o, 'tcx>
) -> SelectionResult<'tcx, SelectionCandidate<'tcx>>
pub(in traits::select::candidate_assembly) fn candidate_from_obligation_no_cache<'o>(
&mut self,
stack: &TraitObligationStack<'o, 'tcx>
) -> SelectionResult<'tcx, SelectionCandidate<'tcx>>[src]
&mut self,
stack: &TraitObligationStack<'o, 'tcx>
) -> SelectionResult<'tcx, SelectionCandidate<'tcx>>
pub(in traits::select) fn assemble_candidates<'o>(
&mut self,
stack: &TraitObligationStack<'o, 'tcx>
) -> Result<SelectionCandidateSet<'tcx>, SelectionError<'tcx>>[src]
&mut self,
stack: &TraitObligationStack<'o, 'tcx>
) -> Result<SelectionCandidateSet<'tcx>, SelectionError<'tcx>>
pub(in traits::select::candidate_assembly) fn assemble_candidates_from_projected_tys(
&mut self,
obligation: &TraitObligation<'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>
)[src]
&mut self,
obligation: &TraitObligation<'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>
)
pub(in traits::select::candidate_assembly) fn assemble_candidates_from_caller_bounds<'o>(
&mut self,
stack: &TraitObligationStack<'o, 'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>
) -> Result<(), SelectionError<'tcx>>[src]
&mut self,
stack: &TraitObligationStack<'o, 'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>
) -> Result<(), SelectionError<'tcx>>
Given an obligation like <SomeTrait for T>, searches the obligations that the caller
supplied to find out whether it is listed among them.
Never affects the inference environment.
pub(in traits::select::candidate_assembly) fn assemble_generator_candidates(
&mut self,
obligation: &TraitObligation<'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>
) -> Result<(), SelectionError<'tcx>>[src]
&mut self,
obligation: &TraitObligation<'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>
) -> Result<(), SelectionError<'tcx>>
pub(in traits::select::candidate_assembly) fn assemble_closure_candidates(
&mut self,
obligation: &TraitObligation<'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>
) -> Result<(), SelectionError<'tcx>>[src]
&mut self,
obligation: &TraitObligation<'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>
) -> Result<(), SelectionError<'tcx>>
Checks for the artificial impl that the compiler will create for an obligation like X : FnMut<..> where X is a closure type.
Note: the type parameters on a closure candidate are modeled as output type parameters and hence do not affect whether this trait is a match or not. They will be unified during the confirmation step.
pub(in traits::select::candidate_assembly) fn assemble_fn_pointer_candidates(
&mut self,
obligation: &TraitObligation<'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>
) -> Result<(), SelectionError<'tcx>>[src]
&mut self,
obligation: &TraitObligation<'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>
) -> Result<(), SelectionError<'tcx>>
Implements one of the Fn() family for a fn pointer.
pub(in traits::select::candidate_assembly) fn assemble_candidates_from_impls(
&mut self,
obligation: &TraitObligation<'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>
) -> Result<(), SelectionError<'tcx>>[src]
&mut self,
obligation: &TraitObligation<'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>
) -> Result<(), SelectionError<'tcx>>
Searches for impls that might apply to obligation.
pub(in traits::select::candidate_assembly) fn assemble_candidates_from_auto_impls(
&mut self,
obligation: &TraitObligation<'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>
) -> Result<(), SelectionError<'tcx>>[src]
&mut self,
obligation: &TraitObligation<'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>
) -> Result<(), SelectionError<'tcx>>
pub(in traits::select::candidate_assembly) fn assemble_candidates_from_object_ty(
&mut self,
obligation: &TraitObligation<'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>
)[src]
&mut self,
obligation: &TraitObligation<'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>
)
Searches for impls that might apply to obligation.
pub(in traits::select::candidate_assembly) fn assemble_candidates_for_unsizing(
&mut self,
obligation: &TraitObligation<'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>
)[src]
&mut self,
obligation: &TraitObligation<'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>
)
Searches for unsizing that might apply to obligation.
pub(in traits::select::candidate_assembly) fn assemble_candidates_for_trait_alias(
&mut self,
obligation: &TraitObligation<'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>
) -> Result<(), SelectionError<'tcx>>[src]
&mut self,
obligation: &TraitObligation<'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>
) -> Result<(), SelectionError<'tcx>>
pub(in traits::select::candidate_assembly) fn assemble_builtin_bound_candidates(
&mut self,
conditions: BuiltinImplConditions<'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>
) -> Result<(), SelectionError<'tcx>>[src]
&mut self,
conditions: BuiltinImplConditions<'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>
) -> Result<(), SelectionError<'tcx>>
Assembles the trait which are built-in to the language itself:
Copy, Clone and Sized.
impl<'cx, 'tcx> SelectionContext<'cx, 'tcx>[src]
pub(in traits::select) fn confirm_candidate(
&mut self,
obligation: &TraitObligation<'tcx>,
candidate: SelectionCandidate<'tcx>
) -> Result<Selection<'tcx>, SelectionError<'tcx>>[src]
&mut self,
obligation: &TraitObligation<'tcx>,
candidate: SelectionCandidate<'tcx>
) -> Result<Selection<'tcx>, SelectionError<'tcx>>
pub(in traits::select::confirmation) fn confirm_projection_candidate(
&mut self,
obligation: &TraitObligation<'tcx>,
idx: usize
) -> Result<Vec<PredicateObligation<'tcx>>, SelectionError<'tcx>>[src]
&mut self,
obligation: &TraitObligation<'tcx>,
idx: usize
) -> Result<Vec<PredicateObligation<'tcx>>, SelectionError<'tcx>>
pub(in traits::select::confirmation) fn confirm_param_candidate(
&mut self,
obligation: &TraitObligation<'tcx>,
param: PolyTraitRef<'tcx>
) -> Vec<PredicateObligation<'tcx>>[src]
&mut self,
obligation: &TraitObligation<'tcx>,
param: PolyTraitRef<'tcx>
) -> Vec<PredicateObligation<'tcx>>
pub(in traits::select::confirmation) fn confirm_builtin_candidate(
&mut self,
obligation: &TraitObligation<'tcx>,
has_nested: bool
) -> ImplSourceBuiltinData<PredicateObligation<'tcx>>[src]
&mut self,
obligation: &TraitObligation<'tcx>,
has_nested: bool
) -> ImplSourceBuiltinData<PredicateObligation<'tcx>>
pub(in traits::select::confirmation) fn confirm_auto_impl_candidate(
&mut self,
obligation: &TraitObligation<'tcx>,
trait_def_id: DefId
) -> ImplSourceAutoImplData<PredicateObligation<'tcx>>[src]
&mut self,
obligation: &TraitObligation<'tcx>,
trait_def_id: DefId
) -> ImplSourceAutoImplData<PredicateObligation<'tcx>>
This handles the case where a auto trait Foo impl is being used.
The idea is that the impl applies to X : Foo if the following conditions are met:
- For each constituent type
YinX,Y : Fooholds - For each where-clause
Cdeclared onFoo,[Self => X] Cholds.
pub(in traits::select::confirmation) fn vtable_auto_impl(
&mut self,
obligation: &TraitObligation<'tcx>,
trait_def_id: DefId,
nested: Binder<Vec<Ty<'tcx>>>
) -> ImplSourceAutoImplData<PredicateObligation<'tcx>>[src]
&mut self,
obligation: &TraitObligation<'tcx>,
trait_def_id: DefId,
nested: Binder<Vec<Ty<'tcx>>>
) -> ImplSourceAutoImplData<PredicateObligation<'tcx>>
See confirm_auto_impl_candidate.
pub(in traits::select::confirmation) fn confirm_impl_candidate(
&mut self,
obligation: &TraitObligation<'tcx>,
impl_def_id: DefId
) -> ImplSourceUserDefinedData<'tcx, PredicateObligation<'tcx>>[src]
&mut self,
obligation: &TraitObligation<'tcx>,
impl_def_id: DefId
) -> ImplSourceUserDefinedData<'tcx, PredicateObligation<'tcx>>
pub(in traits::select::confirmation) fn vtable_impl(
&mut self,
impl_def_id: DefId,
substs: Normalized<'tcx, SubstsRef<'tcx>>,
cause: ObligationCause<'tcx>,
recursion_depth: usize,
param_env: ParamEnv<'tcx>
) -> ImplSourceUserDefinedData<'tcx, PredicateObligation<'tcx>>[src]
&mut self,
impl_def_id: DefId,
substs: Normalized<'tcx, SubstsRef<'tcx>>,
cause: ObligationCause<'tcx>,
recursion_depth: usize,
param_env: ParamEnv<'tcx>
) -> ImplSourceUserDefinedData<'tcx, PredicateObligation<'tcx>>
pub(in traits::select::confirmation) fn confirm_object_candidate(
&mut self,
obligation: &TraitObligation<'tcx>,
index: usize
) -> Result<ImplSourceObjectData<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>>[src]
&mut self,
obligation: &TraitObligation<'tcx>,
index: usize
) -> Result<ImplSourceObjectData<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>>
pub(in traits::select::confirmation) fn confirm_fn_pointer_candidate(
&mut self,
obligation: &TraitObligation<'tcx>
) -> Result<ImplSourceFnPointerData<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>>[src]
&mut self,
obligation: &TraitObligation<'tcx>
) -> Result<ImplSourceFnPointerData<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>>
pub(in traits::select::confirmation) fn confirm_trait_alias_candidate(
&mut self,
obligation: &TraitObligation<'tcx>,
alias_def_id: DefId
) -> ImplSourceTraitAliasData<'tcx, PredicateObligation<'tcx>>[src]
&mut self,
obligation: &TraitObligation<'tcx>,
alias_def_id: DefId
) -> ImplSourceTraitAliasData<'tcx, PredicateObligation<'tcx>>
pub(in traits::select::confirmation) fn confirm_generator_candidate(
&mut self,
obligation: &TraitObligation<'tcx>
) -> Result<ImplSourceGeneratorData<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>>[src]
&mut self,
obligation: &TraitObligation<'tcx>
) -> Result<ImplSourceGeneratorData<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>>
pub(in traits::select::confirmation) fn confirm_closure_candidate(
&mut self,
obligation: &TraitObligation<'tcx>
) -> Result<ImplSourceClosureData<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>>[src]
&mut self,
obligation: &TraitObligation<'tcx>
) -> Result<ImplSourceClosureData<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>>
pub(in traits::select::confirmation) fn confirm_poly_trait_refs(
&mut self,
obligation_cause: ObligationCause<'tcx>,
obligation_param_env: ParamEnv<'tcx>,
obligation_trait_ref: PolyTraitRef<'tcx>,
expected_trait_ref: PolyTraitRef<'tcx>
) -> Result<Vec<PredicateObligation<'tcx>>, SelectionError<'tcx>>[src]
&mut self,
obligation_cause: ObligationCause<'tcx>,
obligation_param_env: ParamEnv<'tcx>,
obligation_trait_ref: PolyTraitRef<'tcx>,
expected_trait_ref: PolyTraitRef<'tcx>
) -> Result<Vec<PredicateObligation<'tcx>>, SelectionError<'tcx>>
In the case of closure types and fn pointers, we currently treat the input type parameters on the trait as outputs. This means that when we have a match we have only considered the self type, so we have to go back and make sure to relate the argument types too. This is kind of wrong, but since we control the full set of impls, also not that wrong, and it DOES yield better error messages (since we don't report errors as if there is no applicable impl, but rather report errors are about mismatched argument types.
Here is an example. Imagine we have a closure expression
and we desugared it so that the type of the expression is
Closure, and Closure expects i32 as argument. Then it
is "as if" the compiler generated this impl:
impl Fn(i32) for Closure { ... }
Now imagine our obligation is Closure: Fn(usize). So far
we have matched the self type Closure. At this point we'll
compare the i32 to usize and generate an error.
Note that this checking occurs after the impl has selected, because these output type parameters should not affect the selection of the impl. Therefore, if there is a mismatch, we report an error to the user.
pub(in traits::select::confirmation) fn confirm_builtin_unsize_candidate(
&mut self,
obligation: &TraitObligation<'tcx>
) -> Result<ImplSourceBuiltinData<PredicateObligation<'tcx>>, SelectionError<'tcx>>[src]
&mut self,
obligation: &TraitObligation<'tcx>
) -> Result<ImplSourceBuiltinData<PredicateObligation<'tcx>>, SelectionError<'tcx>>
impl<'cx, 'tcx> SelectionContext<'cx, 'tcx>[src]
pub fn new(infcx: &'cx InferCtxt<'cx, 'tcx>) -> SelectionContext<'cx, 'tcx>[src]
pub fn intercrate(
infcx: &'cx InferCtxt<'cx, 'tcx>
) -> SelectionContext<'cx, 'tcx>[src]
infcx: &'cx InferCtxt<'cx, 'tcx>
) -> SelectionContext<'cx, 'tcx>
pub fn with_negative(
infcx: &'cx InferCtxt<'cx, 'tcx>,
allow_negative_impls: bool
) -> SelectionContext<'cx, 'tcx>[src]
infcx: &'cx InferCtxt<'cx, 'tcx>,
allow_negative_impls: bool
) -> SelectionContext<'cx, 'tcx>
pub fn with_query_mode(
infcx: &'cx InferCtxt<'cx, 'tcx>,
query_mode: TraitQueryMode
) -> SelectionContext<'cx, 'tcx>[src]
infcx: &'cx InferCtxt<'cx, 'tcx>,
query_mode: TraitQueryMode
) -> SelectionContext<'cx, 'tcx>
pub fn enable_tracking_intercrate_ambiguity_causes(&mut self)[src]
Enables tracking of intercrate ambiguity causes. These are used in coherence to give improved diagnostics. We don't do this until we detect a coherence error because it can lead to false overflow results (#47139) and because it costs computation time.
pub fn take_intercrate_ambiguity_causes(
&mut self
) -> Vec<IntercrateAmbiguityCause>[src]
&mut self
) -> Vec<IntercrateAmbiguityCause>
Gets the intercrate ambiguity causes collected since tracking was enabled and disables tracking at the same time. If tracking is not enabled, just returns an empty vector.
pub fn infcx(&self) -> &'cx InferCtxt<'cx, 'tcx>[src]
pub fn tcx(&self) -> TyCtxt<'tcx>[src]
pub fn select(
&mut self,
obligation: &TraitObligation<'tcx>
) -> SelectionResult<'tcx, Selection<'tcx>>[src]
&mut self,
obligation: &TraitObligation<'tcx>
) -> SelectionResult<'tcx, Selection<'tcx>>
Attempts to satisfy the obligation. If successful, this will affect the surrounding type environment by performing unification.
pub fn predicate_may_hold_fatal(
&mut self,
obligation: &PredicateObligation<'tcx>
) -> bool[src]
&mut self,
obligation: &PredicateObligation<'tcx>
) -> bool
Evaluates whether the obligation obligation can be satisfied (by any means).
pub fn evaluate_root_obligation(
&mut self,
obligation: &PredicateObligation<'tcx>
) -> Result<EvaluationResult, OverflowError>[src]
&mut self,
obligation: &PredicateObligation<'tcx>
) -> Result<EvaluationResult, OverflowError>
Evaluates whether the obligation obligation can be satisfied
and returns an EvaluationResult. This is meant for the
initial call.
pub(in traits::select) fn evaluation_probe(
&mut self,
op: impl FnOnce(&mut Self) -> Result<EvaluationResult, OverflowError>
) -> Result<EvaluationResult, OverflowError>[src]
&mut self,
op: impl FnOnce(&mut Self) -> Result<EvaluationResult, OverflowError>
) -> Result<EvaluationResult, OverflowError>
pub(in traits::select) fn evaluate_predicates_recursively<'o, I>(
&mut self,
stack: TraitObligationStackList<'o, 'tcx>,
predicates: I
) -> Result<EvaluationResult, OverflowError> where
I: IntoIterator<Item = PredicateObligation<'tcx>> + Debug, [src]
&mut self,
stack: TraitObligationStackList<'o, 'tcx>,
predicates: I
) -> Result<EvaluationResult, OverflowError> where
I: IntoIterator<Item = PredicateObligation<'tcx>> + Debug,
Evaluates the predicates in predicates recursively. Note that
this applies projections in the predicates, and therefore
is run within an inference probe.
pub(in traits::select) fn evaluate_predicate_recursively<'o>(
&mut self,
previous_stack: TraitObligationStackList<'o, 'tcx>,
obligation: PredicateObligation<'tcx>
) -> Result<EvaluationResult, OverflowError>[src]
&mut self,
previous_stack: TraitObligationStackList<'o, 'tcx>,
obligation: PredicateObligation<'tcx>
) -> Result<EvaluationResult, OverflowError>
pub(in traits::select) fn evaluate_trait_predicate_recursively<'o>(
&mut self,
previous_stack: TraitObligationStackList<'o, 'tcx>,
obligation: TraitObligation<'tcx>
) -> Result<EvaluationResult, OverflowError>[src]
&mut self,
previous_stack: TraitObligationStackList<'o, 'tcx>,
obligation: TraitObligation<'tcx>
) -> Result<EvaluationResult, OverflowError>
pub(in traits::select) fn check_evaluation_cycle(
&mut self,
stack: &TraitObligationStack<'_, 'tcx>
) -> Option<EvaluationResult>[src]
&mut self,
stack: &TraitObligationStack<'_, 'tcx>
) -> Option<EvaluationResult>
If there is any previous entry on the stack that precisely
matches this obligation, then we can assume that the
obligation is satisfied for now (still all other conditions
must be met of course). One obvious case this comes up is
marker traits like Send. Think of a linked list:
struct List
Box<List<T>> will be Send if T is Send and
Option<Box<List<T>>> is Send, and in turn
Option<Box<List<T>>> is Send if Box<List<T>> is
Send.
Note that we do this comparison using the fresh_trait_ref
fields. Because these have all been freshened using
self.freshener, we can be sure that (a) this will not
affect the inferencer state and (b) that if we see two
fresh regions with the same index, they refer to the same
unbound type variable.
pub(in traits::select) fn evaluate_stack<'o>(
&mut self,
stack: &TraitObligationStack<'o, 'tcx>
) -> Result<EvaluationResult, OverflowError>[src]
&mut self,
stack: &TraitObligationStack<'o, 'tcx>
) -> Result<EvaluationResult, OverflowError>
pub fn coinductive_match<I>(&mut self, cycle: I) -> bool where
I: Iterator<Item = Predicate<'tcx>>, [src]
I: Iterator<Item = Predicate<'tcx>>,
For defaulted traits, we use a co-inductive strategy to solve, so
that recursion is ok. This routine returns true if the top of the
stack (cycle[0]):
- is a defaulted trait,
- it also appears in the backtrace at some position
X, - all the predicates at positions
X..betweenXand the top are also defaulted traits.
pub(in traits::select) fn coinductive_predicate(
&self,
predicate: Predicate<'tcx>
) -> bool[src]
&self,
predicate: Predicate<'tcx>
) -> bool
pub(in traits::select) fn evaluate_candidate<'o>(
&mut self,
stack: &TraitObligationStack<'o, 'tcx>,
candidate: &SelectionCandidate<'tcx>
) -> Result<EvaluationResult, OverflowError>[src]
&mut self,
stack: &TraitObligationStack<'o, 'tcx>,
candidate: &SelectionCandidate<'tcx>
) -> Result<EvaluationResult, OverflowError>
Further evaluates candidate to decide whether all type parameters match and whether nested
obligations are met. Returns whether candidate remains viable after this further
scrutiny.
pub(in traits::select) fn check_evaluation_cache(
&self,
param_env: ParamEnv<'tcx>,
trait_ref: PolyTraitRef<'tcx>
) -> Option<EvaluationResult>[src]
&self,
param_env: ParamEnv<'tcx>,
trait_ref: PolyTraitRef<'tcx>
) -> Option<EvaluationResult>
pub(in traits::select) fn insert_evaluation_cache(
&mut self,
param_env: ParamEnv<'tcx>,
trait_ref: PolyTraitRef<'tcx>,
dep_node: DepNodeIndex,
result: EvaluationResult
)[src]
&mut self,
param_env: ParamEnv<'tcx>,
trait_ref: PolyTraitRef<'tcx>,
dep_node: DepNodeIndex,
result: EvaluationResult
)
pub(in traits::select) fn add_depth<T: 'cx, I: Iterator<Item = &'cx mut Obligation<'tcx, T>>>(
&self,
it: I,
min_depth: usize
)[src]
&self,
it: I,
min_depth: usize
)
For various reasons, it's possible for a subobligation
to have a lower recursion_depth than the obligation used to create it.
Projection sub-obligations may be returned from the projection cache,
which results in obligations with an 'old' recursion_depth.
Additionally, methods like InferCtxt.subtype_predicate produce
subobligations without taking in a 'parent' depth, causing the
generated subobligations to have a recursion_depth of 0.
To ensure that obligation_depth never decreasees, we force all subobligations to have at least the depth of the original obligation.
pub(in traits::select) fn check_recursion_limit<T: Display + TypeFoldable<'tcx>, V: Display + TypeFoldable<'tcx>>(
&self,
obligation: &Obligation<'tcx, T>,
error_obligation: &Obligation<'tcx, V>
) -> Result<(), OverflowError>[src]
&self,
obligation: &Obligation<'tcx, T>,
error_obligation: &Obligation<'tcx, V>
) -> Result<(), OverflowError>
Checks that the recursion limit has not been exceeded.
The weird return type of this function allows it to be used with the try (?)
operator within certain functions.
pub(in traits::select) fn in_task<OP, R>(
&mut self,
op: OP
) -> (R, DepNodeIndex) where
OP: FnOnce(&mut Self) -> R, [src]
&mut self,
op: OP
) -> (R, DepNodeIndex) where
OP: FnOnce(&mut Self) -> R,
pub(in traits::select) fn filter_negative_and_reservation_impls(
&mut self,
candidate: SelectionCandidate<'tcx>
) -> SelectionResult<'tcx, SelectionCandidate<'tcx>>[src]
&mut self,
candidate: SelectionCandidate<'tcx>
) -> SelectionResult<'tcx, SelectionCandidate<'tcx>>
pub(in traits::select) fn is_knowable<'o>(
&mut self,
stack: &TraitObligationStack<'o, 'tcx>
) -> Option<Conflict>[src]
&mut self,
stack: &TraitObligationStack<'o, 'tcx>
) -> Option<Conflict>
pub(in traits::select) fn can_use_global_caches(
&self,
param_env: ParamEnv<'tcx>
) -> bool[src]
&self,
param_env: ParamEnv<'tcx>
) -> bool
Returns true if the global caches can be used.
Do note that if the type itself is not in the
global tcx, the local caches will be used.
pub(in traits::select) fn check_candidate_cache(
&mut self,
param_env: ParamEnv<'tcx>,
cache_fresh_trait_pred: PolyTraitPredicate<'tcx>
) -> Option<SelectionResult<'tcx, SelectionCandidate<'tcx>>>[src]
&mut self,
param_env: ParamEnv<'tcx>,
cache_fresh_trait_pred: PolyTraitPredicate<'tcx>
) -> Option<SelectionResult<'tcx, SelectionCandidate<'tcx>>>
pub(in traits::select) fn can_cache_candidate(
&self,
result: &SelectionResult<'tcx, SelectionCandidate<'tcx>>
) -> bool[src]
&self,
result: &SelectionResult<'tcx, SelectionCandidate<'tcx>>
) -> bool
Determines whether can we safely cache the result
of selecting an obligation. This is almost always true,
except when dealing with certain ParamCandidates.
Ordinarily, a ParamCandidate will contain no inference variables,
since it was usually produced directly from a DefId. However,
certain cases (currently only librustdoc's blanket impl finder),
a ParamEnv may be explicitly constructed with inference types.
When this is the case, we do not want to cache the resulting selection
candidate. This is due to the fact that it might not always be possible
to equate the obligation's trait ref and the candidate's trait ref,
if more constraints end up getting added to an inference variable.
Because of this, we always want to re-run the full selection
process for our obligation the next time we see it, since
we might end up picking a different SelectionCandidate (or none at all).
pub(in traits::select) fn insert_candidate_cache(
&mut self,
param_env: ParamEnv<'tcx>,
cache_fresh_trait_pred: PolyTraitPredicate<'tcx>,
dep_node: DepNodeIndex,
candidate: SelectionResult<'tcx, SelectionCandidate<'tcx>>
)[src]
&mut self,
param_env: ParamEnv<'tcx>,
cache_fresh_trait_pred: PolyTraitPredicate<'tcx>,
dep_node: DepNodeIndex,
candidate: SelectionResult<'tcx, SelectionCandidate<'tcx>>
)
pub(in traits::select) fn match_projection_obligation_against_definition_bounds(
&mut self,
obligation: &TraitObligation<'tcx>
) -> SmallVec<[usize; 2]>[src]
&mut self,
obligation: &TraitObligation<'tcx>
) -> SmallVec<[usize; 2]>
Matches a predicate against the bounds of its self type.
Given an obligation like <T as Foo>::Bar: Baz where the self type is
a projection, look at the bounds of T::Bar, see if we can find a
Baz bound. We return indexes into the list returned by
tcx.item_bounds for any applicable bounds.
pub(in traits::select) fn match_normalize_trait_ref(
&mut self,
obligation: &TraitObligation<'tcx>,
trait_bound: PolyTraitRef<'tcx>,
placeholder_trait_ref: TraitRef<'tcx>
) -> Result<Option<PolyTraitRef<'tcx>>, ()>[src]
&mut self,
obligation: &TraitObligation<'tcx>,
trait_bound: PolyTraitRef<'tcx>,
placeholder_trait_ref: TraitRef<'tcx>
) -> Result<Option<PolyTraitRef<'tcx>>, ()>
Equates the trait in obligation with trait bound. If the two traits
can be equated and the normalized trait bound doesn't contain inference
variables or placeholders, the normalized bound is returned.
pub(in traits::select) fn evaluate_where_clause<'o>(
&mut self,
stack: &TraitObligationStack<'o, 'tcx>,
where_clause_trait_ref: PolyTraitRef<'tcx>
) -> Result<EvaluationResult, OverflowError>[src]
&mut self,
stack: &TraitObligationStack<'o, 'tcx>,
where_clause_trait_ref: PolyTraitRef<'tcx>
) -> Result<EvaluationResult, OverflowError>
pub(in traits) fn match_projection_projections(
&mut self,
obligation: &Obligation<'tcx, ProjectionTy<'tcx>>,
obligation_trait_ref: &TraitRef<'tcx>,
data: &PolyProjectionPredicate<'tcx>,
potentially_unnormalized_candidates: bool
) -> bool[src]
&mut self,
obligation: &Obligation<'tcx, ProjectionTy<'tcx>>,
obligation_trait_ref: &TraitRef<'tcx>,
data: &PolyProjectionPredicate<'tcx>,
potentially_unnormalized_candidates: bool
) -> bool
pub(in traits::select) fn candidate_should_be_dropped_in_favor_of(
&mut self,
victim: &EvaluatedCandidate<'tcx>,
other: &EvaluatedCandidate<'tcx>,
needs_infer: bool
) -> bool[src]
&mut self,
victim: &EvaluatedCandidate<'tcx>,
other: &EvaluatedCandidate<'tcx>,
needs_infer: bool
) -> bool
Returns true if victim should be dropped in favor of
other. Generally speaking we will drop duplicate
candidates and prefer where-clause candidates.
See the comment for "SelectionCandidate" for more details.
pub(in traits::select) fn sized_conditions(
&mut self,
obligation: &TraitObligation<'tcx>
) -> BuiltinImplConditions<'tcx>[src]
&mut self,
obligation: &TraitObligation<'tcx>
) -> BuiltinImplConditions<'tcx>
pub(in traits::select) fn copy_clone_conditions(
&mut self,
obligation: &TraitObligation<'tcx>
) -> BuiltinImplConditions<'tcx>[src]
&mut self,
obligation: &TraitObligation<'tcx>
) -> BuiltinImplConditions<'tcx>
pub(in traits::select) fn constituent_types_for_ty(
&self,
t: Ty<'tcx>
) -> Vec<Ty<'tcx>>[src]
&self,
t: Ty<'tcx>
) -> Vec<Ty<'tcx>>
For default impls, we need to break apart a type into its "constituent types" -- meaning, the types that it contains.
Here are some (simple) examples:
(i32, u32) -> [i32, u32] Foo where struct Foo { x: i32, y: u32 } -> [i32, u32] Bar<i32> where struct Bar<T> { x: T, y: u32 } -> [i32, u32] Zed<i32> where enum Zed { A(T), B(u32) } -> [i32, u32]
pub(in traits::select) fn collect_predicates_for_types(
&mut self,
param_env: ParamEnv<'tcx>,
cause: ObligationCause<'tcx>,
recursion_depth: usize,
trait_def_id: DefId,
types: Binder<Vec<Ty<'tcx>>>
) -> Vec<PredicateObligation<'tcx>>[src]
&mut self,
param_env: ParamEnv<'tcx>,
cause: ObligationCause<'tcx>,
recursion_depth: usize,
trait_def_id: DefId,
types: Binder<Vec<Ty<'tcx>>>
) -> Vec<PredicateObligation<'tcx>>
pub(in traits::select) fn rematch_impl(
&mut self,
impl_def_id: DefId,
obligation: &TraitObligation<'tcx>
) -> Normalized<'tcx, SubstsRef<'tcx>>[src]
&mut self,
impl_def_id: DefId,
obligation: &TraitObligation<'tcx>
) -> Normalized<'tcx, SubstsRef<'tcx>>
pub(in traits::select) fn match_impl(
&mut self,
impl_def_id: DefId,
obligation: &TraitObligation<'tcx>
) -> Result<Normalized<'tcx, SubstsRef<'tcx>>, ()>[src]
&mut self,
impl_def_id: DefId,
obligation: &TraitObligation<'tcx>
) -> Result<Normalized<'tcx, SubstsRef<'tcx>>, ()>
pub(in traits::select) fn fast_reject_trait_refs(
&mut self,
obligation: &TraitObligation<'_>,
impl_trait_ref: &TraitRef<'_>
) -> bool[src]
&mut self,
obligation: &TraitObligation<'_>,
impl_trait_ref: &TraitRef<'_>
) -> bool
pub(in traits::select) fn match_where_clause_trait_ref(
&mut self,
obligation: &TraitObligation<'tcx>,
where_clause_trait_ref: PolyTraitRef<'tcx>
) -> Result<Vec<PredicateObligation<'tcx>>, ()>[src]
&mut self,
obligation: &TraitObligation<'tcx>,
where_clause_trait_ref: PolyTraitRef<'tcx>
) -> Result<Vec<PredicateObligation<'tcx>>, ()>
Normalize where_clause_trait_ref and try to match it against
obligation. If successful, return any predicates that
result from the normalization.
pub(in traits::select) fn match_poly_trait_ref(
&mut self,
obligation: &TraitObligation<'tcx>,
poly_trait_ref: PolyTraitRef<'tcx>
) -> Result<Vec<PredicateObligation<'tcx>>, ()>[src]
&mut self,
obligation: &TraitObligation<'tcx>,
poly_trait_ref: PolyTraitRef<'tcx>
) -> Result<Vec<PredicateObligation<'tcx>>, ()>
Returns Ok if poly_trait_ref being true implies that the
obligation is satisfied.
pub(in traits::select) fn match_fresh_trait_refs(
&self,
previous: PolyTraitRef<'tcx>,
current: PolyTraitRef<'tcx>,
param_env: ParamEnv<'tcx>
) -> bool[src]
&self,
previous: PolyTraitRef<'tcx>,
current: PolyTraitRef<'tcx>,
param_env: ParamEnv<'tcx>
) -> bool
pub(in traits::select) fn push_stack<'o>(
&mut self,
previous_stack: TraitObligationStackList<'o, 'tcx>,
obligation: &'o TraitObligation<'tcx>
) -> TraitObligationStack<'o, 'tcx>[src]
&mut self,
previous_stack: TraitObligationStackList<'o, 'tcx>,
obligation: &'o TraitObligation<'tcx>
) -> TraitObligationStack<'o, 'tcx>
pub(in traits::select) fn closure_trait_ref_unnormalized(
&mut self,
obligation: &TraitObligation<'tcx>,
substs: SubstsRef<'tcx>
) -> PolyTraitRef<'tcx>[src]
&mut self,
obligation: &TraitObligation<'tcx>,
substs: SubstsRef<'tcx>
) -> PolyTraitRef<'tcx>
pub(in traits::select) fn generator_trait_ref_unnormalized(
&mut self,
obligation: &TraitObligation<'tcx>,
substs: SubstsRef<'tcx>
) -> PolyTraitRef<'tcx>[src]
&mut self,
obligation: &TraitObligation<'tcx>,
substs: SubstsRef<'tcx>
) -> PolyTraitRef<'tcx>
pub(in traits::select) fn impl_or_trait_obligations(
&mut self,
cause: ObligationCause<'tcx>,
recursion_depth: usize,
param_env: ParamEnv<'tcx>,
def_id: DefId,
substs: SubstsRef<'tcx>
) -> Vec<PredicateObligation<'tcx>>[src]
&mut self,
cause: ObligationCause<'tcx>,
recursion_depth: usize,
param_env: ParamEnv<'tcx>,
def_id: DefId,
substs: SubstsRef<'tcx>
) -> Vec<PredicateObligation<'tcx>>
Returns the obligations that are implied by instantiating an impl or trait. The obligations are substituted and fully normalized. This is used when confirming an impl or default impl.
Auto Trait Implementations
impl<'cx, 'tcx> !RefUnwindSafe for SelectionContext<'cx, 'tcx>
impl<'cx, 'tcx> !Send for SelectionContext<'cx, 'tcx>
impl<'cx, 'tcx> !Sync for SelectionContext<'cx, 'tcx>
impl<'cx, 'tcx> Unpin for SelectionContext<'cx, 'tcx> where
'tcx: 'cx,
'tcx: 'cx,
impl<'cx, 'tcx> !UnwindSafe for SelectionContext<'cx, 'tcx>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.