Open
Description
It's been mentioned to me that it would be useful to have a list of all the "desugarings" that occur during the compilation process. In particular, which bits of Rust disappear during e.g. HIR conversion, HAIR conversion, MIR conversion. Here are some notes, I'd love to see someone turn some of this into a more detailed writeup! If you're interested, ping me here or (better) on gitter/IRC.
Desugaring that occur during HIR lowering
While constructing the HIR, we perform the following desugarings. It seems worth documenting these at a high-level (e.g, showing the equivalent Rust code), as well as covering some of the mechanisms we use to do it (e.g., the special spans we construct).
- the
?
operator andcatch
blocks- desugared during HIR lowering, as explained here
- the
for
loop- desugared during HIR lowering
- the
if let
andwhile let
forms
Desugaring that occur during MIR lowering
While lowering to MIR, we perform the following desugarings:
-
match
expressions- patterns are desugared during HAIR construction into simpler form
- this for example introduces explicit
&
patterns to implement default binding modes
- this for example introduces explicit
- then, desugared during MIR lowering
- patterns are desugared during HAIR construction into simpler form
- calls
- control-flow into control-flow-graph
Metadata
Metadata
Assignees
Labels
Area: high-level intermediate representation (HIR)Area: mid-level intermediate representation (MIR)Area: typed high-level intermediate representation (THIR)Area: how constructs are desugared over various IR loweringsCategory: enhancementDifficulty: might require advanced knowledgeRelevant to compiler team