Expand description
Passes that undo some lowering done by rustc to recover an operation closer to what the user wrote.
Modules§
- move_
asserts_ to_ statements - Micro-pass: if we want to reconstruct fallible operations, the first step
- reconstruct_
asserts - In the MIR AST, it seems
assertare introduced to check preconditions (for the binops for example). Theassert!introduced by the user introduceif ... then { panic!(...) } else { ...}. This pass introducesassertinstead in order to make the code shorter. - reconstruct_
box_ derefs - Resugar the box derefs that got desugared in elaborated MIR.
- 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 records the enum place as the switch scrutinee and replaces the integer cases with symbolic enum discriminants.
- reconstruct_
panic_ calls - Transform calls to builtin panicking functions into
TerminatorKind::Panic. - reconstruct_
static_ accesses - MIR places can’t name statics, so rustc accesses a static through a temporary holding its
address, e.g.
_1 = const {alloc}; _0 = copy (*_1)where the constant points to the static. We turn*_1back into the static itself and remove the temporary. This is needed to reliably tell what static accesses are unsafe (seeHasSafety), as rustc will lower safe static access to otherwise unsafe raw pointer accesses. - reconstruct_
vec_ boxes - Reconstruct rustc’s
vec![..]lowering based onBox<MaybeUninit<[T; N]>>. - resugar_
drops - Reconstruct conditional drops using the drop flags identified by
detect_drop_flags.