Stream: t-compiler/help

Topic: Rewriting HIR expressions

ange (Apr 10 2019 at 19:12, on Zulip):

are there any examples in rustc of code modifying the HIR representation? There's a for the AST, but not sure where to look for HIR adjustments

davidtwco (Apr 12 2019 at 07:09, on Zulip):

I’m no expert in this area, but if I don’t think there’s an equivalent to for the HIR. There might be a part of the compiler I’m forgetting and someone may correct me, but I don’t think the HIR is generally modified. The HIR is read-only.

I think the closest you’ll get will be in the HIR lowering. It’s not necessarily modifying the HIR, but it’s where the AST is transformed into the HIR and it’s where things like async fn and ? are desugared.

Zoxc (Apr 12 2019 at 07:10, on Zulip):

HIR is read-only.

ange (Apr 12 2019 at 16:18, on Zulip):

thanks, it's good to know for sure :-) I see there's an adjustment table, though not sure if it's safe to use an adjustment to make some subexpressions unreferenced

ange (Apr 12 2019 at 16:20, on Zulip):

i.e. replace e.g. foo.0.y with foo.0 -- this is in the context of RFC2229

ange (Apr 12 2019 at 16:23, on Zulip):

the type should stay the same, but no idea e.g. whether one needs to delete an unreferenced expr or not, etc.

Last update: Sep 18 2020 at 21:00UTC