]> git.lizzy.rs Git - rust.git/blobdiff - tests/target/macros.rs
Tidy up and pass tests
[rust.git] / tests / target / macros.rs
index 805f983d18c785c2831bd72d8834442d146a918a..8db2fbb60ee99ebbd74d77b3322dd738b13b6619 100644 (file)
@@ -141,7 +141,7 @@ fn issue_1555() {
 
 fn issue1178() {
     macro_rules! foo {
-        (#[$attr:meta] $name:ident) => {}
+        (#[$attr: meta] $name: ident) => {};
     }
 
     foo!(
@@ -207,7 +207,7 @@ fn issue_1921() {
             acc += 1;
             acc += 2;
             acc
-        }
+        };
     }
 }
 
@@ -246,11 +246,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
@@ -271,6 +275,7 @@ fn issue2214() {
 }
 
 fn special_case_macros() {
+    let p = eprint!();
     let q = eprint!("{}", 1);
     let r = eprint!(
         "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
@@ -691,6 +696,8 @@ fn special_case_macros() {
         26
     );
 
+    assert!();
+    assert!(result == 42);
     assert!(result == 42, "Ahoy there, {}!", target);
     assert!(
         result == 42,
@@ -730,6 +737,9 @@ fn special_case_macros() {
         26
     );
 
+    assert_eq!();
+    assert_eq!(left);
+    assert_eq!(left, right);
     assert_eq!(left, right, "Ahoy there, {}!", target);
     assert_eq!(
         left, right,
@@ -879,9 +889,7 @@ fn macro_in_pattern_position() {
     };
 }
 
-macro foo() {
-
-}
+macro foo() {}
 
 pub macro bar($x: ident + $y: expr;) {
     fn foo($x: Foo) {
@@ -899,3 +907,11 @@ fn foo() {
         bar();
     }
 }
+
+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,);