Skip to main content

resolve_pending_shift_check

Function resolve_pending_shift_check 

Source
fn resolve_pending_shift_check(body: &mut ExprBody, check: PendingShiftCheck)
Expand description

Resolve a PendingShiftCheck whose shift landed in a different block. We remove the check and compute the shift early, promoted to panic-on-overflow, into a fresh local placed where the check used to be; the fresh local then carries the result to the original destination.

This is correct because rustc has already evaluated both shift operands by the time control reaches the check: the only effects of the shift are that evaluation and the panic-on-overflow, and the overflow check already performs both at that point. Storing the result in a fresh local lets us keep the write to the (not-yet-computed) destination place at the original shift site.