Function rustc_trait_selection::solve::assembly::structural_traits::predicates_for_object_candidate
source · pub(in solve) fn predicates_for_object_candidate<'tcx>(
ecx: &EvalCtxt<'_, 'tcx>,
param_env: ParamEnv<'tcx>,
trait_ref: TraitRef<'tcx>,
object_bound: &'tcx List<PolyExistentialPredicate<'tcx>>
) -> Vec<Goal<'tcx, Predicate<'tcx>>>
Expand description
Assemble a list of predicates that would be present on a theoretical user impl for an object type. These predicates must be checked any time we assemble a built-in object candidate for an object type, since they are not implied by the well-formedness of the type.
For example, given the following traits:
ⓘ
trait Foo: Baz {
type Bar: Copy;
}
trait Baz {}
For the dyn type dyn Foo<Item = Ty>
, we can imagine there being a
pair of theoretical impls:
ⓘ
impl Foo for dyn Foo<Item = Ty>
where
Self: Baz,
<Self as Foo>::Bar: Copy,
{
type Bar = Ty;
}
impl Baz for dyn Foo<Item = Ty> {}
However, in order to make such impls well-formed, we need to do an
additional step of eagerly folding the associated types in the where
clauses of the impl. In this example, that means replacing
<Self as Foo>::Bar
with Ty
in the first impl.