]> git.lizzy.rs Git - rust.git/commitdiff
reduce macro rule duplication in test
authorAlex Burka <alex@alexburka.com>
Mon, 3 Apr 2017 00:26:14 +0000 (00:26 +0000)
committerAlex Burka <alex@alexburka.com>
Sat, 15 Apr 2017 19:06:58 +0000 (19:06 +0000)
src/test/run-pass/macro-pub-matcher.rs

index 1a7529fe2b41209e7db161545a2e898ae94ae2e4..d79f4b65b69e1579da65ccfd8379da143eae648c 100644 (file)
@@ -83,28 +83,12 @@ mod with_pub_restricted_path {
 struct definition.
 */
 macro_rules! vis_parse_struct {
-    /*
-    The rule duplication is currently unavoidable due to the leading attribute
-    matching.
-    */
-    ($(#[$($attrs:tt)*])* pub($($vis:tt)*) struct $name:ident {$($body:tt)*}) => {
-        vis_parse_struct! { @parse_fields $(#[$($attrs)*])*, pub($($vis)*), $name, $($body)* }
-    };
-    ($(#[$($attrs:tt)*])* pub struct $name:ident {$($body:tt)*}) => {
-        vis_parse_struct! { @parse_fields $(#[$($attrs)*])*, pub, $name, $($body)* }
-    };
-    ($(#[$($attrs:tt)*])* struct $name:ident {$($body:tt)*}) => {
-        vis_parse_struct! { @parse_fields $(#[$($attrs)*])*, , $name, $($body)* }
+    ($(#[$($attrs:tt)*])* $vis:vis struct $name:ident {$($body:tt)*}) => {
+        vis_parse_struct! { @parse_fields $(#[$($attrs)*])*, $vis, $name, $($body)* }
     };
 
-    ($(#[$($attrs:tt)*])* pub($($vis:tt)*) struct $name:ident ($($body:tt)*);) => {
-        vis_parse_struct! { @parse_tuple $(#[$($attrs)*])*, pub($($vis)*), $name, $($body)* }
-    };
-    ($(#[$($attrs:tt)*])* pub struct $name:ident ($($body:tt)*);) => {
-        vis_parse_struct! { @parse_tuple $(#[$($attrs)*])*, pub, $name, $($body)* }
-    };
-    ($(#[$($attrs:tt)*])* struct $name:ident ($($body:tt)*);) => {
-        vis_parse_struct! { @parse_tuple $(#[$($attrs)*])*, , $name, $($body)* }
+    ($(#[$($attrs:tt)*])* $vis:vis struct $name:ident ($($body:tt)*);) => {
+        vis_parse_struct! { @parse_tuple $(#[$($attrs)*])*, $vis, $name, $($body)* }
     };
 
     (@parse_fields