Skip to main content

Module print

Module print 

Source
Expand description

The expression/pattern/statement printer: renders a parsed AST fragment back to Bynk source text.

Moved here from bynk-fmt (crate-hygiene A3, design/archive/retired-tracks.md §5) so the checker can quote an expression in a diagnostic without depending on the formatter. The formatter and the checker both call it from here; the text is unchanged byte for byte.

Structs§

WrittenForms
Scope guard installing WRITTEN_SOURCE.

Enums§

LambdaBodySrc
#2712: a lambda’s body as the author wrote it.

Functions§

binop_prec
call_site_actor_src
v0.182 (#664): render a call-site actor clause — by User("bob") or the unit-identity by Visitor.
else_if_tail
#2891: the if an else if desugars to. The parser wraps it in a brace-less block with the same span as the if itself, which tells it apart from an explicit else { if … } (whose block spans its braces).
escape_string
expr_to_string
expr_with_prec
is_pattern_src
#2641: a pattern after is. A record pattern there must be parenthesised — its { would otherwise read as the block that follows the condition — so a record, or an or-pattern with a record alternative, keeps the parentheses the parser dropped as transparent grouping.
lambda_body_src
#2712: the body a lambda with pattern parameters was written with. The parser wraps it, one level per pattern parameter (first outermost), in { let __letElse = __lambdaArg; match __letElse { P => { <rest> } } }; this peels those back off. A lambda with no pattern parameter is untouched.
lambda_param_src
#2712: a lambda parameter as source — the author’s record pattern when it has one (its hidden binder never prints), else the name and any annotation.
let_else_binding
#2010: the hidden binding a let … else desugars into, if s is one — with whether it was <- and the sugar’s own marker.
let_pattern_src
#2010: a let … else pattern as source. After let, a bare name is a binding, not a pattern (let Missing | Late = p would re-parse as a binding named Missing), so a pattern whose text opens with a name not followed by (, . or { keeps the parentheses its author had to write. None, true and false are keywords, not names, so they need none.
literal_text
A literal as written if it has a special form, else canonically escaped.
matches_argument_span
The span of a Matches(…) predicate’s string argument.
omit_unit_tail
#981: whether a block’s () tail should be omitted rather than printed.
pattern_to_string
refinement_to_string
type_ref_to_string