aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe/src/mbe_expander
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_mbe/src/mbe_expander')
-rw-r--r--crates/ra_mbe/src/mbe_expander/matcher.rs6
-rw-r--r--crates/ra_mbe/src/mbe_expander/transcriber.rs10
2 files changed, 8 insertions, 8 deletions
diff --git a/crates/ra_mbe/src/mbe_expander/matcher.rs b/crates/ra_mbe/src/mbe_expander/matcher.rs
index 33b9d483d..3f5136478 100644
--- a/crates/ra_mbe/src/mbe_expander/matcher.rs
+++ b/crates/ra_mbe/src/mbe_expander/matcher.rs
@@ -16,7 +16,7 @@ impl Bindings {
16 fn push_optional(&mut self, name: &SmolStr) { 16 fn push_optional(&mut self, name: &SmolStr) {
17 // FIXME: Do we have a better way to represent an empty token ? 17 // FIXME: Do we have a better way to represent an empty token ?
18 // Insert an empty subtree for empty token 18 // Insert an empty subtree for empty token
19 let tt = tt::Subtree { delimiter: tt::Delimiter::None, token_trees: vec![] }.into(); 19 let tt = tt::Subtree::default().into();
20 self.inner.insert(name.clone(), Binding::Fragment(Fragment::Tokens(tt))); 20 self.inner.insert(name.clone(), Binding::Fragment(Fragment::Tokens(tt)));
21 } 21 }
22 22
@@ -65,7 +65,7 @@ macro_rules! bail {
65} 65}
66 66
67pub(super) fn match_(pattern: &tt::Subtree, src: &tt::Subtree) -> Result<Bindings, ExpandError> { 67pub(super) fn match_(pattern: &tt::Subtree, src: &tt::Subtree) -> Result<Bindings, ExpandError> {
68 assert!(pattern.delimiter == tt::Delimiter::None); 68 assert!(pattern.delimiter == None);
69 69
70 let mut res = Bindings::default(); 70 let mut res = Bindings::default();
71 let mut src = TtIter::new(src); 71 let mut src = TtIter::new(src);
@@ -210,7 +210,7 @@ impl<'a> TtIter<'a> {
210 0 => Err(()), 210 0 => Err(()),
211 1 => Ok(res[0].clone()), 211 1 => Ok(res[0].clone()),
212 _ => Ok(tt::TokenTree::Subtree(tt::Subtree { 212 _ => Ok(tt::TokenTree::Subtree(tt::Subtree {
213 delimiter: tt::Delimiter::None, 213 delimiter: None,
214 token_trees: res.into_iter().cloned().collect(), 214 token_trees: res.into_iter().cloned().collect(),
215 })), 215 })),
216 } 216 }
diff --git a/crates/ra_mbe/src/mbe_expander/transcriber.rs b/crates/ra_mbe/src/mbe_expander/transcriber.rs
index ed094d5bb..f7636db11 100644
--- a/crates/ra_mbe/src/mbe_expander/transcriber.rs
+++ b/crates/ra_mbe/src/mbe_expander/transcriber.rs
@@ -50,7 +50,7 @@ pub(super) fn transcribe(
50 template: &tt::Subtree, 50 template: &tt::Subtree,
51 bindings: &Bindings, 51 bindings: &Bindings,
52) -> Result<tt::Subtree, ExpandError> { 52) -> Result<tt::Subtree, ExpandError> {
53 assert!(template.delimiter == tt::Delimiter::None); 53 assert!(template.delimiter == None);
54 let mut ctx = ExpandCtx { bindings: &bindings, nesting: Vec::new(), var_expanded: false }; 54 let mut ctx = ExpandCtx { bindings: &bindings, nesting: Vec::new(), var_expanded: false };
55 expand_subtree(&mut ctx, template) 55 expand_subtree(&mut ctx, template)
56} 56}
@@ -106,7 +106,7 @@ fn expand_var(ctx: &mut ExpandCtx, v: &SmolStr) -> Result<Fragment, ExpandError>
106 // ``` 106 // ```
107 // We just treat it a normal tokens 107 // We just treat it a normal tokens
108 let tt = tt::Subtree { 108 let tt = tt::Subtree {
109 delimiter: tt::Delimiter::None, 109 delimiter: None,
110 token_trees: vec![ 110 token_trees: vec![
111 tt::Leaf::from(tt::Punct { char: '$', spacing: tt::Spacing::Alone }).into(), 111 tt::Leaf::from(tt::Punct { char: '$', spacing: tt::Spacing::Alone }).into(),
112 tt::Leaf::from(tt::Ident { text: v.clone(), id: tt::TokenId::unspecified() }) 112 tt::Leaf::from(tt::Ident { text: v.clone(), id: tt::TokenId::unspecified() })
@@ -147,7 +147,7 @@ fn expand_repeat(
147 ctx.var_expanded = false; 147 ctx.var_expanded = false;
148 148
149 while let Ok(mut t) = expand_subtree(ctx, template) { 149 while let Ok(mut t) = expand_subtree(ctx, template) {
150 t.delimiter = tt::Delimiter::None; 150 t.delimiter = None;
151 // if no var expanded in the child, we count it as a fail 151 // if no var expanded in the child, we count it as a fail
152 if !ctx.var_expanded { 152 if !ctx.var_expanded {
153 break; 153 break;
@@ -212,7 +212,7 @@ fn expand_repeat(
212 212
213 // Check if it is a single token subtree without any delimiter 213 // Check if it is a single token subtree without any delimiter
214 // e.g {Delimiter:None> ['>'] /Delimiter:None>} 214 // e.g {Delimiter:None> ['>'] /Delimiter:None>}
215 let tt = tt::Subtree { delimiter: tt::Delimiter::None, token_trees: buf }.into(); 215 let tt = tt::Subtree { delimiter: None, token_trees: buf }.into();
216 Ok(Fragment::Tokens(tt)) 216 Ok(Fragment::Tokens(tt))
217} 217}
218 218
@@ -225,7 +225,7 @@ fn push_fragment(buf: &mut Vec<tt::TokenTree>, fragment: Fragment) {
225 225
226fn push_subtree(buf: &mut Vec<tt::TokenTree>, tt: tt::Subtree) { 226fn push_subtree(buf: &mut Vec<tt::TokenTree>, tt: tt::Subtree) {
227 match tt.delimiter { 227 match tt.delimiter {
228 tt::Delimiter::None => buf.extend(tt.token_trees), 228 None => buf.extend(tt.token_trees),
229 _ => buf.push(tt.into()), 229 _ => buf.push(tt.into()),
230 } 230 }
231} 231}