Stream: t-compiler/rust-analyzer

Topic: ConstArg lowering


Lukas Wirth (Jan 25 2021 at 21:46, on Zulip):

Regarding https://github.com/rust-analyzer/rust-analyzer/issues/7432 which just popped up, I wonder how would we go about lowering these const expressions in type param position? I remember having that question in my head when I added them to the HIR. Technically those expressions are bodies right? Which means we would have to lower them lazily but that seems to go against the fact that types are lowered eagerly right?

Florian Diebold (Jan 25 2021 at 21:54, on Zulip):

good question. I do think we could lower them lazily; the type would only contain the ID of the expression (body) anyway

Florian Diebold (Jan 25 2021 at 21:56, on Zulip):

we do need a place to put them, give them IDs and find them again though, which isn't so easy since they can appear everywhere

Florian Diebold (Jan 25 2021 at 22:08, on Zulip):

those bodies could even contain local functions and modules :sweat_smile:

Lukas Wirth (Jan 25 2021 at 22:11, on Zulip):

Oh no, that sounds just lovely :sweat_smile:

Lukas Wirth (Jan 25 2021 at 22:12, on Zulip):

So this might be relevant to the DefMap stuff as well then? Since Jonas Schievink is working on that part to support local items it might be good to keep that in mind

Jonas Schievink [he/him] (Jan 25 2021 at 22:26, on Zulip):

hmm, yeah, tricky

Jonas Schievink [he/him] (Jan 25 2021 at 22:27, on Zulip):

Currently we can compute a Body for any DefWithBodyId, which is just functions, statics and consts

Jonas Schievink [he/him] (Jan 25 2021 at 22:27, on Zulip):

We'd have to extend that to be nestable inside types

Jonas Schievink [he/him] (Jan 25 2021 at 22:28, on Zulip):

Possibly by an AstId-like scheme but for these expression roots?

matklad (Jan 26 2021 at 07:52, on Zulip):

urgh, if only salsa had an db.allocate_id() method...

Last update: Jul 28 2021 at 03:30UTC