Function remap_gat_vars_and_recurse_into_nested_projections

Source
fn remap_gat_vars_and_recurse_into_nested_projections<'tcx>(
    tcx: TyCtxt<'tcx>,
    filter: PredicateFilter,
    item_trait_ref: TraitRef<'tcx>,
    assoc_item_def_id: LocalDefId,
    span: Span,
    clause: Clause<'tcx>,
) -> Option<(Clause<'tcx>, Span)>
Expand description

The code below is quite involved, so let me explain.

We loop here, because we also want to collect vars for nested associated items as well. For example, given a clause like Self::A::B, we want to add that to the item bounds for A, so that we may use that bound in the case that Self::A::B is rigid.

Secondly, regarding bound vars, when we see a where clause that mentions a GAT like for<'a, ...> Self::Assoc<'a, ...>: Bound<'b, ...>, we want to turn that into an item bound on the GAT, where all of the GAT args are substituted with the GAT’s param regions, and then keep all of the other late-bound vars in the bound around. We need to “compress” the binder so that it doesn’t mention any of those vars that were mapped to params.