Skip to content

Commit

Permalink
reduce macro rule duplication in test
Browse files Browse the repository at this point in the history
  • Loading branch information
durka committed Apr 15, 2017
1 parent e0cd766 commit 51c8af5
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions src/test/run-pass/macro-pub-matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,28 +83,12 @@ Ensure that the `:vis` matcher works in a more complex situation: parsing a
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
Expand Down

0 comments on commit 51c8af5

Please sign in to comment.