Skip to content

Commit 51c8af5

Browse files
committed
reduce macro rule duplication in test
1 parent e0cd766 commit 51c8af5

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

src/test/run-pass/macro-pub-matcher.rs

+4-20
Original file line numberDiff line numberDiff line change
@@ -83,28 +83,12 @@ Ensure that the `:vis` matcher works in a more complex situation: parsing a
8383
struct definition.
8484
*/
8585
macro_rules! vis_parse_struct {
86-
/*
87-
The rule duplication is currently unavoidable due to the leading attribute
88-
matching.
89-
*/
90-
($(#[$($attrs:tt)*])* pub($($vis:tt)*) struct $name:ident {$($body:tt)*}) => {
91-
vis_parse_struct! { @parse_fields $(#[$($attrs)*])*, pub($($vis)*), $name, $($body)* }
92-
};
93-
($(#[$($attrs:tt)*])* pub struct $name:ident {$($body:tt)*}) => {
94-
vis_parse_struct! { @parse_fields $(#[$($attrs)*])*, pub, $name, $($body)* }
95-
};
96-
($(#[$($attrs:tt)*])* struct $name:ident {$($body:tt)*}) => {
97-
vis_parse_struct! { @parse_fields $(#[$($attrs)*])*, , $name, $($body)* }
86+
($(#[$($attrs:tt)*])* $vis:vis struct $name:ident {$($body:tt)*}) => {
87+
vis_parse_struct! { @parse_fields $(#[$($attrs)*])*, $vis, $name, $($body)* }
9888
};
9989

100-
($(#[$($attrs:tt)*])* pub($($vis:tt)*) struct $name:ident ($($body:tt)*);) => {
101-
vis_parse_struct! { @parse_tuple $(#[$($attrs)*])*, pub($($vis)*), $name, $($body)* }
102-
};
103-
($(#[$($attrs:tt)*])* pub struct $name:ident ($($body:tt)*);) => {
104-
vis_parse_struct! { @parse_tuple $(#[$($attrs)*])*, pub, $name, $($body)* }
105-
};
106-
($(#[$($attrs:tt)*])* struct $name:ident ($($body:tt)*);) => {
107-
vis_parse_struct! { @parse_tuple $(#[$($attrs)*])*, , $name, $($body)* }
90+
($(#[$($attrs:tt)*])* $vis:vis struct $name:ident ($($body:tt)*);) => {
91+
vis_parse_struct! { @parse_tuple $(#[$($attrs)*])*, $vis, $name, $($body)* }
10892
};
10993

11094
(@parse_fields

0 commit comments

Comments
 (0)