Closed
Description
During lowering (rustc_ast_lowering
), universal impl-trait are desugared to extra generic parameters to the current item, and their bounds added to the where clause.
fn foo<T>(u: impl Bar) where T: Foo
becomes
fn foo<T, _U>(u: _U) where T: Foo, _U: Bar
This is done by carrying two vectors inside ImplTraitContext::Universal
.
These vectors are only created by add_implicit_generics
method, and references to them are passed around.
We should prefer having them as fields in LoweringContext
.
Instructions:
- Move the two vectors from
ImplTraitContext::Universal
to field inLoweringContext
; - Take and replace the values of these fields in
with_hir_id_owner
, and assert that the value after the call tof
is empty; - Add a
itctx: ImplTraitContext
parameter toadd_implicit_generics
and assert that these fields are empty on return ifitctxt
is notUniversal
; - Replace all calls to
lower_generics
by calls toadd_implicit_generics
; - Rename
add_implicit_generics
tolower_generics
; - Maybe inline
lower_generics_mut
intolower_generics
(if this simplifies the logic, not sure).
Please contact me on zulip for any question.
Metadata
Metadata
Assignees
Labels
Area: The high-level intermediate representation (HIR)Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Help is requested to fix this issue.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.