If I want to pretty print the HIR in a readable manner, all I have to do is run
cargo rustc -- -Z unpretty=hir
, and the same thing applies to MIR. Why is THIR not given the same love? I find it strange that we can pretty print a modified version of an IR, like hir,identified
and hir,typed
, while not being able to print the IR responsible for MIR construction.
What do you guys think?
There's a slightly pretty version of THIR unpretty. The reason there isn't a fully pretty printer is probably because the people working with THIR (which are not that many, THIR is only used for very few things) didn't find it useful enough to add.
I don't think it would be that useful, when you're working with it you likely want to know the actual data in there like the types etc, which the current version provides.
1 Like
The THIR ("Typed High-Level Intermediate Representation"), previously called HAIR for "High-Level Abstract IR", is another IR used by rustc that is generated after type checking. It is (as of January 2024) used for MIR construction, exhaustiveness checking, and unsafety checking.
These seem pretty important. Can you clarify what slightly pretty version of THIR unpretty is referring to? Is it a rustc flag?