pub(super) fn find_opaque_ty_constraints_for_tait(
tcx: TyCtxt<'_>,
def_id: LocalDefId
) -> Ty<'_>
Expand description
Checks “defining uses” of opaque impl Trait
types to ensure that they meet the restrictions
laid for “higher-order pattern unification”.
This ensures that inference is tractable.
In particular, definitions of opaque types can only use other generics as arguments,
and they cannot repeat an argument. Example:
ⓘ
type Foo<A, B> = impl Bar<A, B>;
// Okay -- `Foo` is applied to two distinct, generic types.
fn a<T, U>() -> Foo<T, U> { .. }
// Not okay -- `Foo` is applied to `T` twice.
fn b<T>() -> Foo<T, T> { .. }
// Not okay -- `Foo` is applied to a non-generic type.
fn b<T>() -> Foo<T, u32> { .. }