Skip to main content

omit_unit_tail

Function omit_unit_tail 

Source
pub fn omit_unit_tail(b: &Block) -> bool
Expand description

#981: whether a block’s () tail should be omitted rather than printed.

A () tail — whether the parser synthesised it (Block::implicit_tail) or the user wrote it out explicitly — is exactly the block’s default value, so dropping it is loss-free: the parser re-derives the same implicit unit tail either way (v0.7 / v0.146, ADR 0170).

Omitting it is not just an idempotency nicety, it is required for correctness whenever anything precedes the tail (a statement, a case’s stub clause): Bynk has no statement terminator, so a printed () immediately after a preceding line’s last token re-attaches to it as a zero-arg call on re-parse (x / () → x()) rather than staying two separate constructs. #735 only special-cased the implicit-tail shape; #981 found the identical corruption for an explicit () tail (e.g. the last statement of a match arm’s block), which is exactly as dangerous once anything comes before it. So this covers both, structurally, rather than special-casing another syntactic position.