# Function rustc_trait_selection::traits::wf::extend_cause_with_original_assoc_item_obligation

source ·

    fn extend_cause_with_original_assoc_item_obligation<'tcx>(
        tcx: TyCtxt<'tcx>,
        item: Option<&Item<'tcx>>,
        cause: &mut ObligationCause<'tcx>,
        pred: Predicate<'tcx>
    )

Expand description

Points the cause span of a super predicate at the relevant associated type.

Given a trait impl item:

ⓘ

    impl TargetTrait for TargetType {
       type Assoc = SomeType;
    }

And a super predicate of `TargetTrait` that has any of the following forms:

1. `<OtherType as OtherTrait>::Assoc == <TargetType as TargetTrait>::Assoc`
2. `<<TargetType as TargetTrait>::Assoc as OtherTrait>::Assoc == OtherType`
3. `<TargetType as TargetTrait>::Assoc: OtherTrait`

Replace the span of the cause with the span of the associated item:

ⓘ

    impl TargetTrait for TargetType {
        type Assoc = SomeType;
    //               ^^^^^^^^ this span
    }

Note that bounds that can be expressed as associated item bounds are not super predicates. This means that form 2 and 3 from above are only relevant if the `GenericArgsRef` of the projection type are not its identity arguments.