From 41b8688438f8ac5832bf31cab1282d3aef50903f Mon Sep 17 00:00:00 2001 From: John Date: Tue, 23 Dec 2025 05:01:25 -0500 Subject: [PATCH] display: newline-indent bare function bodies(?) --- src/ast/display.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ast/display.rs b/src/ast/display.rs index 3d3b2ec..ad07170 100644 --- a/src/ast/display.rs +++ b/src/ast/display.rs @@ -41,7 +41,7 @@ impl Display for Expr { Self::Op(Op::Tuple, exprs) => f.delimit("(", ")").list(exprs, ", "), Self::Op(Op::Group, exprs) => f.list(exprs, ", "), Self::Op(Op::Meta, exprs) => match exprs.as_slice() { - [meta, expr @ ..] => f.delimit(fmt!("#[{meta}]\n"), "").list(expr, ","), + [meta, expr @ ..] => f.delimit(fmt!("#[{meta}] "), "").list(expr, ","), [] => write!(f, "#[]"), }, @@ -182,7 +182,13 @@ impl Display for Bind { match op { BindOp::Match => f.delimit(fmt!("{pat} => "), "").list(exprs, ",!? "), BindOp::Fn | BindOp::Mod | BindOp::Impl => { - f.delimit(fmt!("{pat} "), "").list(exprs, ",!? ") + if let [Anno(Expr::Op(Op::Block, _), _)] = exprs.as_slice() { + f.delimit(fmt!("{pat} "), "").list(exprs, ",!? ") + } else { + // wrap bare function bodies to new line + f.delimit_indented(pat, "") + .list_wrap("\n", exprs, ",!?", "") + } } BindOp::Struct | BindOp::Enum => match pat { Pat::NamedRecord(name, bind) => match bind.as_ref() {