diff --git a/crates/rune/src/fmt/printer.rs b/crates/rune/src/fmt/printer.rs index a662aef27..822f14c72 100644 --- a/crates/rune/src/fmt/printer.rs +++ b/crates/rune/src/fmt/printer.rs @@ -1801,7 +1801,7 @@ impl<'a> Printer<'a> { } ast::Stmt::Item(item, semi) => { self.visit_item(item, *semi)?; - if !matches!(item, ast::Item::Fn(_)) { + if !matches!(item, ast::Item::Const(_) | ast::Item::Fn(_)) { self.writer.newline()?; } } diff --git a/crates/rune/src/tests/format_source.rs b/crates/rune/src/tests/format_source.rs index 0a77eedef..b65faa22b 100644 --- a/crates/rune/src/tests/format_source.rs +++ b/crates/rune/src/tests/format_source.rs @@ -38,11 +38,11 @@ fn bug_693() -> Result<()> { /// https://github.com/rune-rs/rune/issues/703 #[test] -#[ignore] fn bug_703() -> Result<()> { let source = r#"pub fn main() { const TEST = 1; -}"#; +} +"#; assert_format_source(source, None) } @@ -59,6 +59,16 @@ const TEST3 = 1; assert_format_source(source, Some(expected)) } +#[test] +fn fmt_len() -> Result<()> { + let source = r#"pub fn main() { + let var = 1; +} +"#; + + assert_format_source(source, None) +} + #[test] #[ignore] fn fmt_println() -> Result<()> {