are there any examples in rustc of code modifying the HIR representation? There's a
mut_visitor.rs for the AST, but not sure where to look for HIR adjustments
I’m no expert in this area, but if I don’t think there’s an equivalent to
mut_visitor.rs 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.
HIR is read-only.
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
i.e. replace e.g.
foo.0 -- this is in the context of RFC2229
the type should stay the same, but no idea e.g. whether one needs to delete an unreferenced expr or not, etc.