Skip to content

Commit

Permalink
Omit newline for empty macro branches
Browse files Browse the repository at this point in the history
  • Loading branch information
RReverser committed Feb 4, 2018
1 parent 5bd036f commit 9423cdb
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/macros.rs
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions tests/target/macro_not_expr.rs
@@ -1,6 +1,5 @@
macro_rules! test {
($($t: tt)*) => {
};
($($t: tt)*) => {};
}

fn main() {
Expand Down
3 changes: 1 addition & 2 deletions tests/target/macro_rules.rs
Expand Up @@ -4,8 +4,7 @@ macro_rules! m {
$func(x)
}};

() => {
};
() => {};

($item: ident) => {
mod macro_item {
Expand Down
6 changes: 2 additions & 4 deletions tests/target/macros.rs
Expand Up @@ -141,8 +141,7 @@ fn issue_1555() {

fn issue1178() {
macro_rules! foo {
(#[$attr: meta] $name: ident) => {
};
(#[$attr: meta] $name: ident) => {};
}

foo!(
Expand Down Expand Up @@ -890,8 +889,7 @@ fn macro_in_pattern_position() {
};
}

macro foo() {
}
macro foo() {}

pub macro bar($x: ident + $y: expr;) {
fn foo($x: Foo) {
Expand Down

0 comments on commit 9423cdb

Please sign in to comment.