diff options
author | Edwin Cheng <[email protected]> | 2020-12-28 10:51:43 +0000 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2020-12-28 10:51:43 +0000 |
commit | b5c29af02a88d0354ae1cbdabb41d481132f476e (patch) | |
tree | 790b2474b24c320418f6b4c70dce79ae2a6d26e8 /crates/mbe/src/parser.rs | |
parent | b33453f8445d07ecc81f9f19ad66a0c43286c3a5 (diff) |
Special case underscore in mbe meta op
Diffstat (limited to 'crates/mbe/src/parser.rs')
-rw-r--r-- | crates/mbe/src/parser.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/crates/mbe/src/parser.rs b/crates/mbe/src/parser.rs index c3fdd4040..d681905f5 100644 --- a/crates/mbe/src/parser.rs +++ b/crates/mbe/src/parser.rs | |||
@@ -101,8 +101,15 @@ fn next_op<'a>( | |||
101 | Op::Repeat { subtree, separator, kind } | 101 | Op::Repeat { subtree, separator, kind } |
102 | } | 102 | } |
103 | tt::TokenTree::Leaf(leaf) => match leaf { | 103 | tt::TokenTree::Leaf(leaf) => match leaf { |
104 | tt::Leaf::Punct(_) => { | 104 | tt::Leaf::Punct(punct) => { |
105 | return Err(ExpandError::UnexpectedToken); | 105 | static UNDERSCORE: SmolStr = SmolStr::new_inline("_"); |
106 | |||
107 | if punct.char != '_' { | ||
108 | return Err(ExpandError::UnexpectedToken); | ||
109 | } | ||
110 | let name = &UNDERSCORE; | ||
111 | let kind = eat_fragment_kind(src, mode)?; | ||
112 | Op::Var { name, kind } | ||
106 | } | 113 | } |
107 | tt::Leaf::Ident(ident) => { | 114 | tt::Leaf::Ident(ident) => { |
108 | let name = &ident.text; | 115 | let name = &ident.text; |