]> git.lizzy.rs Git - rust.git/blobdiff - tests/target/macros.rs
Preserve trailing comma on macro call when using mixed layout
[rust.git] / tests / target / macros.rs
index a79eb8fb2941e8881f7b79e1675c0f2b8b49eadb..76e538bb85d49fe6a0a0426778153b73a6d87831 100644 (file)
@@ -15,6 +15,8 @@
 fn main() {
     foo!();
 
+    foo!(,);
+
     bar!(a, b, c);
 
     bar!(a, b, c,);
@@ -141,7 +143,7 @@ fn issue_1555() {
 
 fn issue1178() {
     macro_rules! foo {
-        (#[$attr:meta] $name:ident) => {}
+        (#[$attr:meta] $name:ident) => {};
     }
 
     foo!(
@@ -207,7 +209,7 @@ fn issue_1921() {
             acc += 1;
             acc += 2;
             acc
-        }
+        };
     }
 }
 
@@ -246,11 +248,15 @@ fn __bindgen_test_layout_HandleWithDtor_open0_int_close0_instantiation() {
 
 // #878
 macro_rules! try_opt {
-    ($expr:expr) => (match $expr {
-        Some(val) => val,
+    ($expr:expr) => {
+        match $expr {
+            Some(val) => val,
 
-        None => { return None; }
-    })
+            None => {
+                return None;
+            }
+        }
+    };
 }
 
 // #2214
@@ -885,11 +891,9 @@ fn macro_in_pattern_position() {
     };
 }
 
-macro foo() {
+macro foo() {}
 
-}
-
-pub macro bar($x: ident + $y: expr;) {
+pub macro bar($x:ident + $y:expr;) {
     fn foo($x: Foo) {
         long_function(
             a_long_argument_to_a_long_function_is_what_this_is(AAAAAAAAAAAAAAAAAAAAAAAAAAAA),
@@ -906,6 +910,54 @@ fn foo() {
     }
 }
 
+// #2574
+macro_rules! test {
+    () => {{}};
+}
+
 macro lex_err($kind: ident $(, $body: expr)*) {
     Err(QlError::LexError(LexError::$kind($($body,)*)))
 }
+
+// Preserve trailing comma on item-level macro with `()` or `[]`.
+methods![get, post, delete,];
+methods!(get, post, delete,);
+
+// #2588
+macro_rules! m {
+    () => {
+        r#"
+            test
+        "#
+    };
+}
+fn foo() {
+    f!{r#"
+            test
+       "#};
+}
+
+// #2591
+fn foo() {
+    match 0u32 {
+        0 => (),
+        _ => unreachable!(/* obviously */),
+    }
+}
+
+fn foo() {
+    let _ = column!(/* here */);
+}
+
+// #2616
+// Preserve trailing comma when using mixed layout for macro call.
+fn foo() {
+    foo!(
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
+    );
+    foo!(
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+    );
+}