Function rustc_typeck::check::wfcheck::check_existential_types[][src]

Important traits for Vec<u8>
fn check_existential_types<'a, 'fcx, 'gcx, 'tcx>(
    tcx: TyCtxt<'a, 'gcx, 'gcx>,
    fcx: &FnCtxt<'fcx, 'gcx, 'tcx>,
    fn_def_id: DefId,
    span: Span,
    ty: Ty<'tcx>
) -> Vec<Predicate<'tcx>>
🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Checks "defining uses" of existential types to ensure that they meet the restrictions laid for "higher-order pattern unification". This ensures that inference is tractable. In particular, definitions of existential types can only use other generics as arguments, and they cannot repeat an argument. Example:

existential type Foo<A, B>;

// ok -- `Foo` is applied to two distinct, generic types.
fn a<T, U>() -> Foo<T, U> { .. }

// not ok -- `Foo` is applied to `T` twice.
fn b<T>() -> Foo<T, T> { .. }


// not ok -- `Foo` is applied to a non-generic type.
fn b<T>() -> Foo<T, u32> { .. }