diff options
author | Aleksey Kladov <[email protected]> | 2019-02-08 11:49:43 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-02-08 11:49:43 +0000 |
commit | 12e3b4c70b5ef23b2fdfc197296d483680e125f9 (patch) | |
tree | 71baa0e0a62f9f6b61450501c5f821f67badf9e4 /crates/ra_mbe/src/mbe_expander.rs | |
parent | 5cb1d41a30d25cbe136402644bf5434dd667f1e5 (diff) |
reformat the world
Diffstat (limited to 'crates/ra_mbe/src/mbe_expander.rs')
-rw-r--r-- | crates/ra_mbe/src/mbe_expander.rs | 29 |
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 | ||
175 | fn expand_tt( | 168 | fn 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) |