File tree Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -220,9 +220,11 @@ impl MacroDef {
220
220
while src. len ( ) > 0 {
221
221
let rule = Rule :: parse ( & mut src, true ) ?;
222
222
rules. push ( rule) ;
223
- if let Err ( ( ) ) = src. expect_char ( ';' ) {
223
+ if let Err ( ( ) ) = src. expect_any_char ( & [ ';' , ',' ] ) {
224
224
if src. len ( ) > 0 {
225
- return Err ( ParseError :: Expected ( "expected `;`" . to_string ( ) ) ) ;
225
+ return Err ( ParseError :: Expected (
226
+ "expected `;` or `,` to delimit rules" . to_string ( ) ,
227
+ ) ) ;
226
228
}
227
229
break ;
228
230
}
Original file line number Diff line number Diff line change @@ -662,6 +662,21 @@ macro foo {
662
662
. assert_expand_items ( "foo!(bar);" , "fn bar () {}" ) ;
663
663
}
664
664
665
+ #[ test]
666
+ fn test_macro_2_0_panic_2015 ( ) {
667
+ parse_macro2 (
668
+ r#"
669
+ macro panic_2015 {
670
+ () => (
671
+ ),
672
+ (bar) => (
673
+ ),
674
+ }
675
+ "# ,
676
+ )
677
+ . assert_expand_items ( "panic_2015!(bar);" , "" ) ;
678
+ }
679
+
665
680
#[ test]
666
681
fn test_path ( ) {
667
682
parse_macro (
Original file line number Diff line number Diff line change @@ -34,6 +34,17 @@ impl<'a> TtIter<'a> {
34
34
}
35
35
}
36
36
37
+ pub ( crate ) fn expect_any_char ( & mut self , chars : & [ char ] ) -> Result < ( ) , ( ) > {
38
+ match self . next ( ) {
39
+ Some ( tt:: TokenTree :: Leaf ( tt:: Leaf :: Punct ( tt:: Punct { char : c, .. } ) ) )
40
+ if chars. contains ( c) =>
41
+ {
42
+ Ok ( ( ) )
43
+ }
44
+ _ => Err ( ( ) ) ,
45
+ }
46
+ }
47
+
37
48
pub ( crate ) fn expect_subtree ( & mut self ) -> Result < & ' a tt:: Subtree , ( ) > {
38
49
match self . next ( ) {
39
50
Some ( tt:: TokenTree :: Subtree ( it) ) => Ok ( it) ,
You can’t perform that action at this time.
0 commit comments