Skip to main content

match_needs_if_chain

Function match_needs_if_chain 

Source
pub fn match_needs_if_chain(arms: &[MatchArm]) -> bool
Expand description

A match needs the if/else-if lowering (ADR 0169) when any arm carries a guard or a refutable nested payload pattern — a JS switch on .tag can express neither. Flat, unguarded matches keep the switch (zero churn to existing output).

pub since P6.5 (#1159, Decision B) — bynk-lower’s own lowering pass reuses this pure predicate verbatim to decide MatchForm, rather than re-deriving an equivalent one over IrPat’s own shape, so the string emitter’s own if-chain-vs-switch choice and the IR’s own recorded form can never silently disagree. Lives in bynk-ir (not bynk-emit or bynk-lower specifically) since both bynk-emit’s own string emitter and bynk-lower’s IR lowering need it — moved out of bynk-emit::emitter::lower at the P7.12 crate carve, no behaviour change.