Skip to content

Commit 9423cdb

Browse files
committed
Omit newline for empty macro branches
1 parent 5bd036f commit 9423cdb

File tree

4 files changed

+5
-9
lines changed

4 files changed

+5
-9
lines changed

src/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ pub fn rewrite_macro_def(
400400

401401
if has_block_body {
402402
result += new_body.trim();
403-
} else {
403+
} else if !new_body.is_empty() {
404404
result += "\n";
405405
result += &new_body;
406406
result += &mac_indent_str;

tests/target/macro_not_expr.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
macro_rules! test {
2-
($($t: tt)*) => {
3-
};
2+
($($t: tt)*) => {};
43
}
54

65
fn main() {

tests/target/macro_rules.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ macro_rules! m {
44
$func(x)
55
}};
66

7-
() => {
8-
};
7+
() => {};
98

109
($item: ident) => {
1110
mod macro_item {

tests/target/macros.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ fn issue_1555() {
141141

142142
fn issue1178() {
143143
macro_rules! foo {
144-
(#[$attr: meta] $name: ident) => {
145-
};
144+
(#[$attr: meta] $name: ident) => {};
146145
}
147146

148147
foo!(
@@ -890,8 +889,7 @@ fn macro_in_pattern_position() {
890889
};
891890
}
892891

893-
macro foo() {
894-
}
892+
macro foo() {}
895893

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

0 commit comments

Comments
 (0)