aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe/src/mbe_expander.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-04-14 15:16:42 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-04-14 15:16:42 +0100
commit5d35f284f5ac70cde5d758e7c63a38eae0fb0b55 (patch)
tree4cde8df0f4a496bb1f38b3e3479ce462fc1f7426 /crates/ra_mbe/src/mbe_expander.rs
parentfcbd0269545f2b6687a64a868654c74f876b7851 (diff)
parent6646d49f238bb92d55fcb4900830f19faa2994a5 (diff)
Merge #1138
1138: Add L_DOLLAR and R_DOLLAR r=matklad a=edwin0cheng As discussion in issue https://github.com/rust-analyzer/rust-analyzer/issues/1132 and PR #1125 , this PR add 2 `Syntax::Kind` : `L_DOLLAR` and `R_DOLLAR` for representing `Delimiter::None` in mbe and proc_marco. By design, It should not affect the final syntax tree, and will be discard in `TreeSink`. My original idea is handling these 2 tokens case by case, but i found that they will appear in every place in the parser (imagine `tt` matcher). So this PR only handle it in `Parser::do_bump` and `Parser::start`, although It will not fix the `expr` matcher executing order problem in original idea. Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_mbe/src/mbe_expander.rs')
-rw-r--r--crates/ra_mbe/src/mbe_expander.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/crates/ra_mbe/src/mbe_expander.rs b/crates/ra_mbe/src/mbe_expander.rs
index ce41d7225..7a259f338 100644
--- a/crates/ra_mbe/src/mbe_expander.rs
+++ b/crates/ra_mbe/src/mbe_expander.rs
@@ -144,6 +144,19 @@ fn match_lhs(pattern: &crate::Subtree, input: &mut TtCursor) -> Result<Bindings,
144 input.eat_path().ok_or(ExpandError::UnexpectedToken)?.clone(); 144 input.eat_path().ok_or(ExpandError::UnexpectedToken)?.clone();
145 res.inner.insert(text.clone(), Binding::Simple(path.into())); 145 res.inner.insert(text.clone(), Binding::Simple(path.into()));
146 } 146 }
147 "expr" => {
148 let expr =
149 input.eat_expr().ok_or(ExpandError::UnexpectedToken)?.clone();
150 res.inner.insert(text.clone(), Binding::Simple(expr.into()));
151 }
152 "ty" => {
153 let ty = input.eat_ty().ok_or(ExpandError::UnexpectedToken)?.clone();
154 res.inner.insert(text.clone(), Binding::Simple(ty.into()));
155 }
156 "pat" => {
157 let pat = input.eat_pat().ok_or(ExpandError::UnexpectedToken)?.clone();
158 res.inner.insert(text.clone(), Binding::Simple(pat.into()));
159 }
147 _ => return Err(ExpandError::UnexpectedToken), 160 _ => return Err(ExpandError::UnexpectedToken),
148 } 161 }
149 } 162 }