aboutsummaryrefslogtreecommitdiff
path: root/crates/mbe/src/expander
diff options
context:
space:
mode:
authorClemens Wasser <[email protected]>2021-06-03 11:46:56 +0100
committerClemens Wasser <[email protected]>2021-06-03 11:46:56 +0100
commit629e8d1ed0aeabf27a1e1b1d3c8c9134716043e3 (patch)
treec55fdaf665ba247aa5df4f9912290fd5ddd1841a /crates/mbe/src/expander
parent3c6dc0f89dc9c2902d71e8639b4913917a396f8a (diff)
Apply more clippy suggestions and update generated
Diffstat (limited to 'crates/mbe/src/expander')
-rw-r--r--crates/mbe/src/expander/matcher.rs21
1 files changed, 7 insertions, 14 deletions
diff --git a/crates/mbe/src/expander/matcher.rs b/crates/mbe/src/expander/matcher.rs
index 84ca3ff87..c982eb58f 100644
--- a/crates/mbe/src/expander/matcher.rs
+++ b/crates/mbe/src/expander/matcher.rs
@@ -219,7 +219,7 @@ impl BindingsBuilder {
219 bindings 219 bindings
220 } 220 }
221 221
222 fn build_inner(&self, bindings: &mut Bindings, link_nodes: &Vec<LinkNode<Rc<BindingKind>>>) { 222 fn build_inner(&self, bindings: &mut Bindings, link_nodes: &[LinkNode<Rc<BindingKind>>]) {
223 let mut nodes = Vec::new(); 223 let mut nodes = Vec::new();
224 self.collect_nodes(&link_nodes, &mut nodes); 224 self.collect_nodes(&link_nodes, &mut nodes);
225 225
@@ -301,7 +301,7 @@ impl BindingsBuilder {
301 301
302 fn collect_nodes<'a>( 302 fn collect_nodes<'a>(
303 &'a self, 303 &'a self,
304 link_nodes: &'a Vec<LinkNode<Rc<BindingKind>>>, 304 link_nodes: &'a [LinkNode<Rc<BindingKind>>],
305 nodes: &mut Vec<&'a Rc<BindingKind>>, 305 nodes: &mut Vec<&'a Rc<BindingKind>>,
306 ) { 306 ) {
307 link_nodes.iter().for_each(|it| match it { 307 link_nodes.iter().for_each(|it| match it {
@@ -494,15 +494,8 @@ fn match_loop_inner<'t>(
494 } 494 }
495 Some(err) => { 495 Some(err) => {
496 res.add_err(err); 496 res.add_err(err);
497 match match_res.value { 497 if let Some(fragment) = match_res.value {
498 Some(fragment) => { 498 bindings_builder.push_fragment(&mut item.bindings, &name, fragment);
499 bindings_builder.push_fragment(
500 &mut item.bindings,
501 &name,
502 fragment,
503 );
504 }
505 _ => {}
506 } 499 }
507 item.is_error = true; 500 item.is_error = true;
508 error_items.push(item); 501 error_items.push(item);
@@ -578,9 +571,9 @@ fn match_loop(pattern: &MetaTemplate, src: &tt::Subtree) -> Match {
578 ); 571 );
579 stdx::always!(cur_items.is_empty()); 572 stdx::always!(cur_items.is_empty());
580 573
581 if error_items.len() > 0 { 574 if !error_items.is_empty() {
582 error_recover_item = error_items.pop().map(|it| it.bindings); 575 error_recover_item = error_items.pop().map(|it| it.bindings);
583 } else if eof_items.len() > 0 { 576 } else if !eof_items.is_empty() {
584 error_recover_item = Some(eof_items[0].bindings.clone()); 577 error_recover_item = Some(eof_items[0].bindings.clone());
585 } 578 }
586 579
@@ -793,7 +786,7 @@ impl<'a> TtIter<'a> {
793 _ => (), 786 _ => (),
794 } 787 }
795 788
796 let tt = self.next().ok_or_else(|| ())?.clone(); 789 let tt = self.next().ok_or(())?.clone();
797 let punct = match tt { 790 let punct = match tt {
798 tt::TokenTree::Leaf(tt::Leaf::Punct(punct)) if punct.spacing == tt::Spacing::Joint => { 791 tt::TokenTree::Leaf(tt::Leaf::Punct(punct)) if punct.spacing == tt::Spacing::Joint => {
799 punct 792 punct