aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe/src/mbe_expander.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_mbe/src/mbe_expander.rs')
-rw-r--r--crates/ra_mbe/src/mbe_expander.rs29
1 files changed, 7 insertions, 22 deletions
diff --git a/crates/ra_mbe/src/mbe_expander.rs b/crates/ra_mbe/src/mbe_expander.rs
index fb1066eec..31531f4c9 100644
--- a/crates/ra_mbe/src/mbe_expander.rs
+++ b/crates/ra_mbe/src/mbe_expander.rs
@@ -133,11 +133,7 @@ fn match_lhs(pattern: &crate::Subtree, input: &mut TtCursor) -> Option<Bindings>
133 } 133 }
134 _ => return None, 134 _ => return None,
135 }, 135 },
136 crate::TokenTree::Repeat(crate::Repeat { 136 crate::TokenTree::Repeat(crate::Repeat { subtree, kind: _, separator }) => {
137 subtree,
138 kind: _,
139 separator,
140 }) => {
141 while let Some(nested) = match_lhs(subtree, input) { 137 while let Some(nested) = match_lhs(subtree, input) {
142 res.push_nested(nested)?; 138 res.push_nested(nested)?;
143 if let Some(separator) = *separator { 139 if let Some(separator) = *separator {
@@ -166,10 +162,7 @@ fn expand_subtree(
166 .map(|it| expand_tt(it, bindings, nesting)) 162 .map(|it| expand_tt(it, bindings, nesting))
167 .collect::<Option<Vec<_>>>()?; 163 .collect::<Option<Vec<_>>>()?;
168 164
169 Some(tt::Subtree { 165 Some(tt::Subtree { token_trees, delimiter: template.delimiter })
170 token_trees,
171 delimiter: template.delimiter,
172 })
173} 166}
174 167
175fn expand_tt( 168fn expand_tt(
@@ -188,23 +181,15 @@ fn expand_tt(
188 token_trees.push(t.into()) 181 token_trees.push(t.into())
189 } 182 }
190 nesting.pop().unwrap(); 183 nesting.pop().unwrap();
191 tt::Subtree { 184 tt::Subtree { token_trees, delimiter: tt::Delimiter::None }.into()
192 token_trees,
193 delimiter: tt::Delimiter::None,
194 }
195 .into()
196 } 185 }
197 crate::TokenTree::Leaf(leaf) => match leaf { 186 crate::TokenTree::Leaf(leaf) => match leaf {
198 crate::Leaf::Ident(ident) => tt::Leaf::from(tt::Ident { 187 crate::Leaf::Ident(ident) => {
199 text: ident.text.clone(), 188 tt::Leaf::from(tt::Ident { text: ident.text.clone() }).into()
200 }) 189 }
201 .into(),
202 crate::Leaf::Punct(punct) => tt::Leaf::from(punct.clone()).into(), 190 crate::Leaf::Punct(punct) => tt::Leaf::from(punct.clone()).into(),
203 crate::Leaf::Var(v) => bindings.get(&v.text, nesting)?.clone(), 191 crate::Leaf::Var(v) => bindings.get(&v.text, nesting)?.clone(),
204 crate::Leaf::Literal(l) => tt::Leaf::from(tt::Literal { 192 crate::Leaf::Literal(l) => tt::Leaf::from(tt::Literal { text: l.text.clone() }).into(),
205 text: l.text.clone(),
206 })
207 .into(),
208 }, 193 },
209 }; 194 };
210 Some(res) 195 Some(res)