Mutation/Creation of HIR
Depending on what you want to do, you might target the MIR, HIR or AST. Most rustc consumers target the MIR, and it's also the only stage to be available in rustc_public for now.
But in fact, while the MIR and the HIR mostly can map back to source code (via spans), they're not intended to that, so implementing a rewriting tool via them is going to be hard. On the other hand from the AST it's hard to obtain information as you noticed.
In general rustc is just not planned for rewriting tools, as it's not something a compiler usually does (it does some rewriting in diagnostic fixes, but it's very minor). If that's what you want to do, you might want to consider using rust-analyzer instead - while not as accurate as rustc, it is pretty accurate and unlike rustc, it definitely is intended for rewriting source code.
Discussion in the ATmosphere