Skip to main content

reconstruct_overflow_calls

Function reconstruct_overflow_calls 

Source
fn reconstruct_overflow_calls(ctx: &TransformCtx, body: &mut ExprBody)
Expand description

Overflow checks for addition/subtraction/multiplication. They look like:

  r := x checked.+ y;
  assert(move r.1 == false);
  ...
  z := move r.0;

We replace that with:

z := x panic.+ y;

Also sometimes, because of constant promotion, we end up with a lone checked operation without assert. In that case we replace it with its wrapping equivalent.