From 9423cdba82026ce78bb5e24e7af619dde0b56a0e Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Thu, 25 Jan 2018 14:12:18 +0000 Subject: [PATCH] Omit newline for empty macro branches --- src/macros.rs | 2 +- tests/target/macro_not_expr.rs | 3 +-- tests/target/macro_rules.rs | 3 +-- tests/target/macros.rs | 6 ++---- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index f362736ea92..2f7c4262b6b 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -400,7 +400,7 @@ pub fn rewrite_macro_def( if has_block_body { result += new_body.trim(); - } else { + } else if !new_body.is_empty() { result += "\n"; result += &new_body; result += &mac_indent_str; diff --git a/tests/target/macro_not_expr.rs b/tests/target/macro_not_expr.rs index 20dcfe2d622..c76a6492a9d 100644 --- a/tests/target/macro_not_expr.rs +++ b/tests/target/macro_not_expr.rs @@ -1,6 +1,5 @@ macro_rules! test { - ($($t: tt)*) => { - }; + ($($t: tt)*) => {}; } fn main() { diff --git a/tests/target/macro_rules.rs b/tests/target/macro_rules.rs index 4c494c932d6..d5ce0f7309e 100644 --- a/tests/target/macro_rules.rs +++ b/tests/target/macro_rules.rs @@ -4,8 +4,7 @@ macro_rules! m { $func(x) }}; - () => { - }; + () => {}; ($item: ident) => { mod macro_item { diff --git a/tests/target/macros.rs b/tests/target/macros.rs index 83116de7e3d..9b32c6623bb 100644 --- a/tests/target/macros.rs +++ b/tests/target/macros.rs @@ -141,8 +141,7 @@ fn issue_1555() { fn issue1178() { macro_rules! foo { - (#[$attr: meta] $name: ident) => { - }; + (#[$attr: meta] $name: ident) => {}; } foo!( @@ -890,8 +889,7 @@ fn macro_in_pattern_position() { }; } -macro foo() { -} +macro foo() {} pub macro bar($x: ident + $y: expr;) { fn foo($x: Foo) {