Skip to main content

Module resugar

Module resugar 

Source
Expand description

Passes that undo some lowering done by rustc to recover an operation closer to what the user wrote.

Modulesยง

inline_local_panic_functions
panic!() expands to:
move_asserts_to_statements
Micro-pass: if we want to reconstruct fallible operations, the first step
reconstruct_asserts
In the MIR AST, it seems assert are introduced to check preconditions (for the binops for example). The assert! introduced by the user introduce if ... then { panic!(...) } else { ...}. This pass introduces assert instead in order to make the code shorter.
reconstruct_boxes
Micro-pass: reconstruct piecewise box allocations using malloc and ShallowInitBox.
reconstruct_fallible_operations
Micro-pass: remove the dynamic checks for array/slice bounds, overflow, and division by zero.
reconstruct_intrinsics
reconstruct_matches
The way to match on enums in MIR is in two steps: first read the discriminant, then switch on the resulting integer. This pass merges the two into a SwitchKind::Match that directly mentions enum variants.