aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe/src/mbe_expander.rs
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2019-05-02 14:24:51 +0100
committerEdwin Cheng <[email protected]>2019-05-02 14:24:51 +0100
commit35c463315032dcebb38f738cca57581608f19826 (patch)
tree6a48f9cbdf7ecd94488d1fd1705b95c96515272f /crates/ra_mbe/src/mbe_expander.rs
parentb0e7022afe17f35fd0f6960a279e375b19061919 (diff)
Make `vis` matcher optional and fix typo
Diffstat (limited to 'crates/ra_mbe/src/mbe_expander.rs')
-rw-r--r--crates/ra_mbe/src/mbe_expander.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/crates/ra_mbe/src/mbe_expander.rs b/crates/ra_mbe/src/mbe_expander.rs
index d5189b537..1b579f319 100644
--- a/crates/ra_mbe/src/mbe_expander.rs
+++ b/crates/ra_mbe/src/mbe_expander.rs
@@ -206,8 +206,24 @@ fn match_lhs(pattern: &crate::Subtree, input: &mut TtCursor) -> Result<Bindings,
206 ); 206 );
207 } 207 }
208 "vis" => { 208 "vis" => {
209 let vis = input.eat_vis().ok_or(ExpandError::UnexpectedToken)?.clone(); 209 // `vis` is optional
210 res.inner.insert(text.clone(), Binding::Simple(vis.into())); 210 if let Some(vis) = input.try_eat_vis() {
211 let vis = vis.clone();
212 res.inner.insert(text.clone(), Binding::Simple(vis.into()));
213 } else {
214 // FIXME: Do we have a better way to represent an empty token ?
215 // Insert an empty subtree for empty token
216 res.inner.insert(
217 text.clone(),
218 Binding::Simple(
219 tt::Subtree {
220 delimiter: tt::Delimiter::None,
221 token_trees: vec![],
222 }
223 .into(),
224 ),
225 );
226 }
211 } 227 }
212 228
213 _ => return Err(ExpandError::UnexpectedToken), 229 _ => return Err(ExpandError::UnexpectedToken),