Skip to main content

try_fold_into_case_literal

Function try_fold_into_case_literal 

Source
fn try_fold_into_case_literal(expr: &mut MirScalarExpr)
Expand description

Fold rule: if node is If(Eq(x, lit), res, CallVariadic(CaseLiteral{..}, [x, ...])) where the CaseLiteral’s input (exprs[0]) structurally equals x, insert (or overwrite) res into the existing CaseLiteral.

Because we traverse bottom-up, the current If is an earlier arm than anything already in the CaseLiteral. For duplicates, the outer/earlier arm wins per SQL CASE semantics, so we overwrite the existing entry.