pub(crate) fn collect_bound_vars<'tcx, T: TypeFoldable<'tcx>>(
    interner: RustInterner<'tcx>,
    tcx: TyCtxt<'tcx>,
    ty: Binder<'tcx, T>
) -> (T, VariableKinds<RustInterner<'tcx>>, BTreeMap<DefId, u32>)
Expand description

To collect bound vars, we have to do two passes. In the first pass, we collect all BoundRegionKinds and ty::Bounds. In the second pass, we then replace BrNamed into BrAnon. The two separate passes are important, since we can only replace BrNamed with BrAnons with indices after all “real” BrAnons.

It’s important to note that because of prior substitution, we may have late-bound regions, even outside of fn contexts, since this is the best way to prep types for chalk lowering.