## CandidateSource

# Type Alias CandidateSource

    pub type CandidateSource<'tcx> = CandidateSource<TyCtxt<'tcx>>;

## Aliased Type§

    pub enum CandidateSource<'tcx> {
        Impl(DefId),
        BuiltinImpl(BuiltinImplSource),
        ParamEnv(ParamEnvSource),
        AliasBound(AliasBoundKind),
        CoherenceUnknowable,
    }

## Variants§

§

### Impl(DefId)

A user written impl.

##### §Examples

    fn main() {
        let x: Vec<u32> = Vec::new();
        // This uses the impl from the standard library to prove `Vec<T>: Clone`.
        let y = x.clone();
    }

§

### BuiltinImpl(BuiltinImplSource)

A builtin impl generated by the compiler. When adding a new special trait, try to use actual impls whenever possible. Builtin impls should only be used in cases where the impl cannot be manually be written.

Notable examples are auto traits, `Sized`, and `DiscriminantKind`. For a list of all traits with builtin impls, check out the `EvalCtxt::assemble_builtin_impl_candidates` method.

§

### ParamEnv(ParamEnvSource)

An assumption from the environment. Stores a `ParamEnvSource`, since we prefer non-global param-env candidates in candidate assembly.

##### §Examples

    fn is_clone<T: Clone>(x: T) -> (T, T) {
        // This uses the assumption `T: Clone` from the `where`-bounds
        // to prove `T: Clone`.
        (x.clone(), x)
    }

§

### AliasBound(AliasBoundKind)

If the self type is an alias type, e.g. an opaque type or a projection, we know the bounds on that alias to hold even without knowing its concrete underlying type.

More precisely this candidate is using the `n-th` bound in the `item_bounds` of the self type.

##### §Examples

    trait Trait {
        type Assoc: Clone;
    }

    fn foo<T: Trait>(x: <T as Trait>::Assoc) {
        // We prove `<T as Trait>::Assoc` by looking at the bounds on `Assoc` in
        // in the trait definition.
        let _y = x.clone();
    }

§

### CoherenceUnknowable

A candidate that is registered only during coherence to represent some yet-unknown impl that could be produced downstream without violating orphan rules.

## Layout§

Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.