pub(super) trait GoalKind<'tcx>: TypeFoldable<TyCtxt<'tcx>> + Copy + Eq + Display {
Show 26 methods // Required methods fn self_ty(self) -> Ty<'tcx>; fn trait_ref(self, tcx: TyCtxt<'tcx>) -> TraitRef<'tcx>; fn with_self_ty(self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> Self; fn trait_def_id(self, tcx: TyCtxt<'tcx>) -> DefId; fn probe_and_match_goal_against_assumption( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self>, assumption: Clause<'tcx>, then: impl FnOnce(&mut EvalCtxt<'_, 'tcx>) -> QueryResult<'tcx> ) -> QueryResult<'tcx>; fn consider_impl_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self>, impl_def_id: DefId ) -> QueryResult<'tcx>; fn consider_error_guaranteed_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, guar: ErrorGuaranteed ) -> QueryResult<'tcx>; fn consider_auto_trait_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>; fn consider_trait_alias_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>; fn consider_builtin_sized_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>; fn consider_builtin_copy_clone_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>; fn consider_builtin_pointer_like_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>; fn consider_builtin_fn_ptr_trait_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>; fn consider_builtin_fn_trait_candidates( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self>, kind: ClosureKind ) -> QueryResult<'tcx>; fn consider_builtin_tuple_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>; fn consider_builtin_pointee_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>; fn consider_builtin_future_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>; fn consider_builtin_generator_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>; fn consider_builtin_discriminant_kind_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>; fn consider_builtin_destruct_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>; fn consider_builtin_transmute_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>; fn consider_structural_builtin_unsize_candidates( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> Vec<(CanonicalResponse<'tcx>, BuiltinImplSource)>; fn consider_unsize_to_dyn_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>; // Provided methods fn consider_implied_clause( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self>, assumption: Clause<'tcx>, requirements: impl IntoIterator<Item = Goal<'tcx, Predicate<'tcx>>> ) -> QueryResult<'tcx> { ... } fn consider_alias_bound_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self>, assumption: Clause<'tcx> ) -> QueryResult<'tcx> { ... } fn consider_object_bound_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self>, assumption: Clause<'tcx> ) -> QueryResult<'tcx> { ... }
}
Expand description

Methods used to assemble candidates for either trait or projection goals.

Required Methods§

source

fn self_ty(self) -> Ty<'tcx>

source

fn trait_ref(self, tcx: TyCtxt<'tcx>) -> TraitRef<'tcx>

source

fn with_self_ty(self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> Self

source

fn trait_def_id(self, tcx: TyCtxt<'tcx>) -> DefId

source

fn probe_and_match_goal_against_assumption( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self>, assumption: Clause<'tcx>, then: impl FnOnce(&mut EvalCtxt<'_, 'tcx>) -> QueryResult<'tcx> ) -> QueryResult<'tcx>

Try equating an assumption predicate against a goal’s predicate. If it holds, then execute the then callback, which should do any additional work, then produce a response (typically by executing EvalCtxt::evaluate_added_goals_and_make_canonical_response).

source

fn consider_impl_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self>, impl_def_id: DefId ) -> QueryResult<'tcx>

source

fn consider_error_guaranteed_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, guar: ErrorGuaranteed ) -> QueryResult<'tcx>

If the predicate contained an error, we want to avoid emitting unnecessary trait errors but still want to emit errors for other trait goals. We have some special handling for this case.

Trait goals always hold while projection goals never do. This is a bit arbitrary but prevents incorrect normalization while hiding any trait errors.

source

fn consider_auto_trait_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

A type implements an auto trait if its components do as well.

These components are given by built-in rules from structural_traits::instantiate_constituent_tys_for_auto_trait.

source

fn consider_trait_alias_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

A trait alias holds if the RHS traits and where clauses hold.

source

fn consider_builtin_sized_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

A type is Copy or Clone if its components are Sized.

These components are given by built-in rules from structural_traits::instantiate_constituent_tys_for_sized_trait.

source

fn consider_builtin_copy_clone_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

A type is Copy or Clone if its components are Copy or Clone.

These components are given by built-in rules from structural_traits::instantiate_constituent_tys_for_copy_clone_trait.

source

fn consider_builtin_pointer_like_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

A type is PointerLike if we can compute its layout, and that layout matches the layout of usize.

source

fn consider_builtin_fn_ptr_trait_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

A type is a FnPtr if it is of FnPtr type.

source

fn consider_builtin_fn_trait_candidates( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self>, kind: ClosureKind ) -> QueryResult<'tcx>

A callable type (a closure, fn def, or fn ptr) is known to implement the Fn<A> family of traits where A is given by the signature of the type.

source

fn consider_builtin_tuple_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

Tuple is implemented if the Self type is a tuple.

source

fn consider_builtin_pointee_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

Pointee is always implemented.

See the projection implementation for the Metadata types for all of the built-in types. For structs, the metadata type is given by the struct tail.

source

fn consider_builtin_future_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

A generator (that comes from an async desugaring) is known to implement Future<Output = O>, where O is given by the generator’s return type that was computed during type-checking.

source

fn consider_builtin_generator_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

A generator (that doesn’t come from an async desugaring) is known to implement Generator<R, Yield = Y, Return = O>, given the resume, yield, and return types of the generator computed during type-checking.

source

fn consider_builtin_discriminant_kind_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source

fn consider_builtin_destruct_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source

fn consider_builtin_transmute_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source

fn consider_structural_builtin_unsize_candidates( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> Vec<(CanonicalResponse<'tcx>, BuiltinImplSource)>

Consider (possibly several) candidates to upcast or unsize a type to another type, excluding the coercion of a sized type into a dyn Trait.

We return the BuiltinImplSource for each candidate as it is needed for unsize coercion in hir typeck and because it is difficult to otherwise recompute this for codegen. This is a bit of a mess but the easiest way to maintain the existing behavior for now.

source

fn consider_unsize_to_dyn_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

Consider the Unsize candidate corresponding to coercing a sized type into a dyn Trait.

This is computed separately from the rest of the Unsize candidates since it is only done once per self type, and not once per normalization step (in assemble_candidates_via_self_ty).

Provided Methods§

source

fn consider_implied_clause( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self>, assumption: Clause<'tcx>, requirements: impl IntoIterator<Item = Goal<'tcx, Predicate<'tcx>>> ) -> QueryResult<'tcx>

Consider a clause, which consists of a “assumption” and some “requirements”, to satisfy a goal. If the requirements hold, then attempt to satisfy our goal by equating it with the assumption.

source

fn consider_alias_bound_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self>, assumption: Clause<'tcx> ) -> QueryResult<'tcx>

Consider a bound originating from the item bounds of an alias. For this we require that the well-formed requirements of the self type of the goal are “satisfied from the param-env”. See EvalCtxt::validate_alias_bound_self_from_param_env.

source

fn consider_object_bound_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self>, assumption: Clause<'tcx> ) -> QueryResult<'tcx>

Consider a clause specifically for a dyn Trait self type. This requires additionally checking all of the supertraits and object bounds to hold, since they’re not implied by the well-formedness of the object type.

Implementations on Foreign Types§

source§

impl<'tcx> GoalKind<'tcx> for TraitPredicate<'tcx>

source§

fn consider_structural_builtin_unsize_candidates( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> Vec<(CanonicalResponse<'tcx>, BuiltinImplSource)>

trait Trait {
    fn foo(&self);
}
// results in the following builtin impl
impl<'a, T: Trait + 'a> Unsize<dyn Trait + 'a> for T {}
source§

fn self_ty(self) -> Ty<'tcx>

source§

fn trait_ref(self, _: TyCtxt<'tcx>) -> TraitRef<'tcx>

source§

fn with_self_ty(self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> Self

source§

fn trait_def_id(self, _: TyCtxt<'tcx>) -> DefId

source§

fn consider_impl_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, TraitPredicate<'tcx>>, impl_def_id: DefId ) -> QueryResult<'tcx>

source§

fn consider_error_guaranteed_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, _guar: ErrorGuaranteed ) -> QueryResult<'tcx>

source§

fn probe_and_match_goal_against_assumption( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self>, assumption: Clause<'tcx>, then: impl FnOnce(&mut EvalCtxt<'_, 'tcx>) -> QueryResult<'tcx> ) -> QueryResult<'tcx>

source§

fn consider_auto_trait_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

fn consider_trait_alias_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

fn consider_builtin_sized_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

fn consider_builtin_copy_clone_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

fn consider_builtin_pointer_like_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

fn consider_builtin_fn_ptr_trait_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

fn consider_builtin_fn_trait_candidates( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self>, goal_kind: ClosureKind ) -> QueryResult<'tcx>

source§

fn consider_builtin_tuple_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

fn consider_builtin_pointee_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

fn consider_builtin_future_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

fn consider_builtin_generator_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

fn consider_builtin_discriminant_kind_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

fn consider_builtin_destruct_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

fn consider_builtin_transmute_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

fn consider_unsize_to_dyn_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

impl<'tcx> GoalKind<'tcx> for ProjectionPredicate<'tcx>

source§

fn consider_error_guaranteed_candidate( _ecx: &mut EvalCtxt<'_, 'tcx>, _guar: ErrorGuaranteed ) -> QueryResult<'tcx>

Fail to normalize if the predicate contains an error, alternatively, we could normalize to ty::Error and succeed. Can experiment with this to figure out what results in better error messages.

source§

fn self_ty(self) -> Ty<'tcx>

source§

fn trait_ref(self, tcx: TyCtxt<'tcx>) -> TraitRef<'tcx>

source§

fn with_self_ty(self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> Self

source§

fn trait_def_id(self, tcx: TyCtxt<'tcx>) -> DefId

source§

fn probe_and_match_goal_against_assumption( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self>, assumption: Clause<'tcx>, then: impl FnOnce(&mut EvalCtxt<'_, 'tcx>) -> QueryResult<'tcx> ) -> QueryResult<'tcx>

source§

fn consider_impl_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, ProjectionPredicate<'tcx>>, impl_def_id: DefId ) -> QueryResult<'tcx>

source§

fn consider_auto_trait_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

fn consider_trait_alias_candidate( _ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

fn consider_builtin_sized_candidate( _ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

fn consider_builtin_copy_clone_candidate( _ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

fn consider_builtin_pointer_like_candidate( _ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

fn consider_builtin_fn_ptr_trait_candidate( _ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

fn consider_builtin_fn_trait_candidates( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self>, goal_kind: ClosureKind ) -> QueryResult<'tcx>

source§

fn consider_builtin_tuple_candidate( _ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

fn consider_builtin_pointee_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

fn consider_builtin_future_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

fn consider_builtin_generator_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

fn consider_unsize_to_dyn_candidate( _ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

fn consider_structural_builtin_unsize_candidates( _ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> Vec<(CanonicalResponse<'tcx>, BuiltinImplSource)>

source§

fn consider_builtin_discriminant_kind_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

fn consider_builtin_destruct_candidate( _ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

source§

fn consider_builtin_transmute_candidate( _ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self> ) -> QueryResult<'tcx>

Implementors§