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 Jan 25, 2018
1 parent 5bf08f0 commit 62b5bed
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
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 62b5bed

Please sign in to comment.