[−][src]Function rustc_typeck::check::wfcheck::check_opaque_types
pub(in check::wfcheck) fn check_opaque_types<'fcx, 'tcx>(
tcx: TyCtxt<'tcx>,
fcx: &FnCtxt<'fcx, 'tcx>,
fn_def_id: LocalDefId,
span: Span,
ty: Ty<'tcx>
)
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> { .. }