Skip to main content

reduce_call_binary_identity

Function reduce_call_binary_identity 

Source
fn reduce_call_binary_identity(e: &mut MirScalarExpr) -> bool
Expand description

Rewrites a call whose literal operand makes it the identity function on the other operand to that operand, returning whether it fired.

Only patterns that can change neither error nor null behavior are listed: evaluation at the identity operand is infallible for every listed function (division by one cannot error; adding an all-zero interval cannot leave the timestamp domain; trimming the empty character set cannot grow the string), every listed function propagates nulls, and the surviving operand has the value and type of the original call. Functions that can error even at their identity are deliberately absent: e.g. text_concat and repeat(s, 1) re-validate the length of an oversized operand, so eliding them would suppress that error. Floats are also absent: -0.0 + 0.0 is +0.0, so the additive identities are not exact, and we keep the float story all-or-nothing for legibility. Numerics are absent pending an answer on result scale.