Skip to content

Commit 6d6259f

Browse files
committed
Document why we allow escaping bound vars in LTA norm
1 parent 356f2d0 commit 6d6259f

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

compiler/rustc_trait_selection/src/traits/normalize.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,21 @@ impl<'a, 'b, 'tcx> AssocTypeNormalizer<'a, 'b, 'tcx> {
299299
);
300300
}
301301

302+
// We don't replace bound vars in the generic arguments of the free alias with
303+
// placeholders. This doesn't cause any issues as instantiating parameters with
304+
// bound variables is special-cased to rewrite the debruijn index to be higher
305+
// whenever we fold through a binder.
306+
//
307+
// However, we do replace any escaping bound vars in the resulting goals with
308+
// placeholders as the trait solver does not expect to encounter escaping bound
309+
// vars in obligations.
310+
//
311+
// FIXME(lazy_type_alias): Check how much this actually matters for perf before
312+
// stabilization. This is a bit weird and generally not how we handle binders in
313+
// the compiler so ideally we'd do the same boundvar->placeholder->boundvar dance
314+
// that other kinds of normalization do.
302315
let infcx = self.selcx.infcx;
303316
self.obligations.extend(
304-
// FIXME(BoxyUwU):
305-
// FIXME(lazy_type_alias):
306-
// It seems suspicious to instantiate the predicates with arguments that might be bound vars,
307-
// we might wind up instantiating one of these bound vars underneath a hrtb.
308317
infcx.tcx.predicates_of(free.def_id).instantiate_own(infcx.tcx, free.args).map(
309318
|(mut predicate, span)| {
310319
if free.has_escaping_bound_vars() {

0 commit comments

Comments
 (0)