Skip to content

Commit

Permalink
fix new line after const
Browse files Browse the repository at this point in the history
  • Loading branch information
SWW13 authored and udoprog committed Jun 14, 2024
1 parent 4b8743d commit 02f8437
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion crates/rune/src/fmt/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
}
}
Expand Down
14 changes: 12 additions & 2 deletions crates/rune/src/tests/format_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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<()> {
Expand Down

0 comments on commit 02f8437

Please sign in to comment.