]> git.lizzy.rs Git - rust.git/blobdiff - src/test/run-pass/macro-at-most-once-rep.rs
No separator for `?`. No `?` as a separator.
[rust.git] / src / test / run-pass / macro-at-most-once-rep.rs
index b7e942f938321ae8f033a65909cea38975d856e2..c08effe549328705ae5843475b2c4f54c5032033 100644 (file)
@@ -32,25 +32,13 @@ macro_rules! foo {
     } }
 }
 
-macro_rules! baz {
-    ($($a:ident),? ; $num:expr) => { { // comma separator is meaningless for `?`
-        let mut x = 0;
-
-        $(
-            x += $a;
-         )?
-
-        assert_eq!(x, $num);
-    } }
-}
-
 macro_rules! barplus {
     ($($a:ident)?+ ; $num:expr) => { {
         let mut x = 0;
 
         $(
             x += $a;
-         )+
+         )?
 
         assert_eq!(x, $num);
     } }
@@ -62,7 +50,7 @@ macro_rules! barstar {
 
         $(
             x += $a;
-         )*
+         )?
 
         assert_eq!(x, $num);
     } }
@@ -74,15 +62,10 @@ pub fn main() {
     // accept 0 or 1 repetitions
     foo!( ; 0);
     foo!(a ; 1);
-    baz!( ; 0);
-    baz!(a ; 1);
 
     // Make sure using ? as a separator works as before
-    barplus!(a ; 1);
-    barplus!(a?a ; 2);
-    barplus!(a?a?a ; 3);
-    barstar!( ; 0);
-    barstar!(a ; 1);
-    barstar!(a?a ; 2);
-    barstar!(a?a?a ; 3);
+    barplus!(+ ; 0);
+    barplus!(a + ; 1);
+    barstar!(* ; 0);
+    barstar!(a * ; 1);
 }