diff options
Diffstat (limited to 'crates/ra_mbe')
-rw-r--r-- | crates/ra_mbe/src/parser.rs | 6 | ||||
-rw-r--r-- | crates/ra_mbe/src/tests.rs | 1 |
2 files changed, 6 insertions, 1 deletions
diff --git a/crates/ra_mbe/src/parser.rs b/crates/ra_mbe/src/parser.rs index 10a6f300a..034150432 100644 --- a/crates/ra_mbe/src/parser.rs +++ b/crates/ra_mbe/src/parser.rs | |||
@@ -90,7 +90,11 @@ fn next_op<'a>( | |||
90 | ) -> Result<Op<'a>, ExpandError> { | 90 | ) -> Result<Op<'a>, ExpandError> { |
91 | let res = match first { | 91 | let res = match first { |
92 | tt::TokenTree::Leaf(tt::Leaf::Punct(tt::Punct { char: '$', .. })) => { | 92 | tt::TokenTree::Leaf(tt::Leaf::Punct(tt::Punct { char: '$', .. })) => { |
93 | let second = src.next().ok_or_else(|| err!("bad var 1"))?; | 93 | // Note that the '$' itself is a valid token inside macro_rules. |
94 | let second = match src.next() { | ||
95 | None => return Ok(Op::TokenTree(first)), | ||
96 | Some(it) => it, | ||
97 | }; | ||
94 | match second { | 98 | match second { |
95 | tt::TokenTree::Subtree(subtree) => { | 99 | tt::TokenTree::Subtree(subtree) => { |
96 | let (separator, kind) = parse_repeat(src)?; | 100 | let (separator, kind) = parse_repeat(src)?; |
diff --git a/crates/ra_mbe/src/tests.rs b/crates/ra_mbe/src/tests.rs index cb228702f..1dba82915 100644 --- a/crates/ra_mbe/src/tests.rs +++ b/crates/ra_mbe/src/tests.rs | |||
@@ -23,6 +23,7 @@ mod rule_parsing { | |||
23 | check("($($i:ident)*) => ($_)"); | 23 | check("($($i:ident)*) => ($_)"); |
24 | check("($($true:ident)*) => ($true)"); | 24 | check("($($true:ident)*) => ($true)"); |
25 | check("($($false:ident)*) => ($false)"); | 25 | check("($($false:ident)*) => ($false)"); |
26 | check("($) => ($)"); | ||
26 | } | 27 | } |
27 | 28 | ||
28 | #[test] | 29 | #[test] |