about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/macros.rs14
-rw-r--r--tests/source/extern.rs4
-rw-r--r--tests/target/extern.rs4
3 files changed, 16 insertions, 6 deletions
diff --git a/src/macros.rs b/src/macros.rs
index fdbe3374615..664f152e8be 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -112,6 +112,7 @@ fn rewrite_macro_name(
 fn return_macro_parse_failure_fallback(
     context: &RewriteContext<'_>,
     indent: Indent,
+    position: MacroPosition,
     span: Span,
 ) -> Option<String> {
     // Mark this as a failure however we format it
@@ -140,7 +141,11 @@ fn return_macro_parse_failure_fallback(
     ));
 
     // Return the snippet unmodified if the macro is not block-like
-    Some(context.snippet(span).to_owned())
+    let mut snippet = context.snippet(span).to_owned();
+    if position == MacroPosition::Item {
+        snippet.push(';');
+    }
+    Some(snippet)
 }
 
 pub(crate) fn rewrite_macro(
@@ -233,7 +238,12 @@ fn rewrite_macro_inner(
     } = match parse_macro_args(context, ts, style, is_forced_bracket) {
         Some(args) => args,
         None => {
-            return return_macro_parse_failure_fallback(context, shape.indent, mac.span());
+            return return_macro_parse_failure_fallback(
+                context,
+                shape.indent,
+                position,
+                mac.span(),
+            );
         }
     };
 
diff --git a/tests/source/extern.rs b/tests/source/extern.rs
index 5b981385d2b..f51ba6e98c9 100644
--- a/tests/source/extern.rs
+++ b/tests/source/extern.rs
@@ -84,9 +84,9 @@ macro_rules! x {
 
 extern "macros" {
     x!(ident);
-    // x!(#); FIXME
+    x!(#);
     x![ident];
-    // x![#]; FIXME
+    x![#];
     x! {ident}
     x! {#}
 }
diff --git a/tests/target/extern.rs b/tests/target/extern.rs
index 570d21c17df..d1741360cfd 100644
--- a/tests/target/extern.rs
+++ b/tests/target/extern.rs
@@ -89,9 +89,9 @@ macro_rules! x {
 
 extern "macros" {
     x!(ident);
-    // x!(#); FIXME
+    x!(#);
     x![ident];
-    // x![#]; FIXME
+    x![#];
     x! {ident}
     x! {#}
 }