diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-06-13 08:18:49 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-06-13 08:18:49 +0100 |
commit | adbee621a75f47e0da4f30d7205dfce009138865 (patch) | |
tree | ed8dcbba37de566f00d119817e141bb8293ce164 /crates/mbe/src/expander/matcher.rs | |
parent | f107b0f1e223dba33cb9850ce44bcbb4345eef52 (diff) | |
parent | 5ac6804bb3a07b959e8c2c3534255a8d6bb4948c (diff) |
Merge #9242
9242: Clippy r=matklad a=Maan2003
Best viewed commit wise
Co-authored-by: Maan2003 <[email protected]>
Diffstat (limited to 'crates/mbe/src/expander/matcher.rs')
-rw-r--r-- | crates/mbe/src/expander/matcher.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/crates/mbe/src/expander/matcher.rs b/crates/mbe/src/expander/matcher.rs index c982eb58f..c0e1705c0 100644 --- a/crates/mbe/src/expander/matcher.rs +++ b/crates/mbe/src/expander/matcher.rs | |||
@@ -121,7 +121,7 @@ impl Match { | |||
121 | 121 | ||
122 | /// Matching errors are added to the `Match`. | 122 | /// Matching errors are added to the `Match`. |
123 | pub(super) fn match_(pattern: &MetaTemplate, input: &tt::Subtree) -> Match { | 123 | pub(super) fn match_(pattern: &MetaTemplate, input: &tt::Subtree) -> Match { |
124 | let mut res = match_loop(pattern, &input); | 124 | let mut res = match_loop(pattern, input); |
125 | res.bound_count = count(res.bindings.bindings()); | 125 | res.bound_count = count(res.bindings.bindings()); |
126 | return res; | 126 | return res; |
127 | 127 | ||
@@ -202,7 +202,7 @@ impl BindingsBuilder { | |||
202 | } | 202 | } |
203 | 203 | ||
204 | fn push_nested(&mut self, parent: &mut BindingsIdx, child: &BindingsIdx) { | 204 | fn push_nested(&mut self, parent: &mut BindingsIdx, child: &BindingsIdx) { |
205 | let BindingsIdx(idx, nidx) = self.copy(&child); | 205 | let BindingsIdx(idx, nidx) = self.copy(child); |
206 | self.nodes[parent.0].push(LinkNode::Node(Rc::new(BindingKind::Nested(idx, nidx)))); | 206 | self.nodes[parent.0].push(LinkNode::Node(Rc::new(BindingKind::Nested(idx, nidx)))); |
207 | } | 207 | } |
208 | 208 | ||
@@ -221,7 +221,7 @@ impl BindingsBuilder { | |||
221 | 221 | ||
222 | fn build_inner(&self, bindings: &mut Bindings, link_nodes: &[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 | ||
226 | for cmd in nodes { | 226 | for cmd in nodes { |
227 | match &**cmd { | 227 | match &**cmd { |
@@ -282,7 +282,7 @@ impl BindingsBuilder { | |||
282 | 282 | ||
283 | nested_refs.into_iter().for_each(|iter| { | 283 | nested_refs.into_iter().for_each(|iter| { |
284 | let mut child_bindings = Bindings::default(); | 284 | let mut child_bindings = Bindings::default(); |
285 | self.build_inner(&mut child_bindings, &iter); | 285 | self.build_inner(&mut child_bindings, iter); |
286 | nested.push(child_bindings) | 286 | nested.push(child_bindings) |
287 | }) | 287 | }) |
288 | } | 288 | } |
@@ -417,7 +417,7 @@ fn match_loop_inner<'t>( | |||
417 | let sep_len = item.sep.as_ref().map_or(0, Separator::tt_count); | 417 | let sep_len = item.sep.as_ref().map_or(0, Separator::tt_count); |
418 | if item.sep.is_some() && sep_idx != sep_len { | 418 | if item.sep.is_some() && sep_idx != sep_len { |
419 | let sep = item.sep.as_ref().unwrap(); | 419 | let sep = item.sep.as_ref().unwrap(); |
420 | if src.clone().expect_separator(&sep, sep_idx) { | 420 | if src.clone().expect_separator(sep, sep_idx) { |
421 | item.dot.next(); | 421 | item.dot.next(); |
422 | item.sep_parsed = Some(sep_idx + 1); | 422 | item.sep_parsed = Some(sep_idx + 1); |
423 | try_push!(next_items, item); | 423 | try_push!(next_items, item); |
@@ -487,7 +487,7 @@ fn match_loop_inner<'t>( | |||
487 | item.meta_result = Some((fork, match_res)); | 487 | item.meta_result = Some((fork, match_res)); |
488 | try_push!(bb_items, item); | 488 | try_push!(bb_items, item); |
489 | } else { | 489 | } else { |
490 | bindings_builder.push_optional(&mut item.bindings, &name); | 490 | bindings_builder.push_optional(&mut item.bindings, name); |
491 | item.dot.next(); | 491 | item.dot.next(); |
492 | cur_items.push(item); | 492 | cur_items.push(item); |
493 | } | 493 | } |
@@ -495,7 +495,7 @@ fn match_loop_inner<'t>( | |||
495 | Some(err) => { | 495 | Some(err) => { |
496 | res.add_err(err); | 496 | res.add_err(err); |
497 | if let Some(fragment) = match_res.value { | 497 | if let Some(fragment) = match_res.value { |
498 | bindings_builder.push_fragment(&mut item.bindings, &name, fragment); | 498 | bindings_builder.push_fragment(&mut item.bindings, name, fragment); |
499 | } | 499 | } |
500 | item.is_error = true; | 500 | item.is_error = true; |
501 | error_items.push(item); | 501 | error_items.push(item); |
@@ -504,7 +504,7 @@ fn match_loop_inner<'t>( | |||
504 | } | 504 | } |
505 | } | 505 | } |
506 | OpDelimited::Op(Op::Leaf(leaf)) => { | 506 | OpDelimited::Op(Op::Leaf(leaf)) => { |
507 | if let Err(err) = match_leaf(&leaf, &mut src.clone()) { | 507 | if let Err(err) = match_leaf(leaf, &mut src.clone()) { |
508 | res.add_err(err); | 508 | res.add_err(err); |
509 | item.is_error = true; | 509 | item.is_error = true; |
510 | } else { | 510 | } else { |
@@ -640,10 +640,10 @@ fn match_loop(pattern: &MetaTemplate, src: &tt::Subtree) -> Match { | |||
640 | let (iter, match_res) = item.meta_result.take().unwrap(); | 640 | let (iter, match_res) = item.meta_result.take().unwrap(); |
641 | match match_res.value { | 641 | match match_res.value { |
642 | Some(fragment) => { | 642 | Some(fragment) => { |
643 | bindings_builder.push_fragment(&mut item.bindings, &name, fragment); | 643 | bindings_builder.push_fragment(&mut item.bindings, name, fragment); |
644 | } | 644 | } |
645 | None if match_res.err.is_none() => { | 645 | None if match_res.err.is_none() => { |
646 | bindings_builder.push_optional(&mut item.bindings, &name); | 646 | bindings_builder.push_optional(&mut item.bindings, name); |
647 | } | 647 | } |
648 | _ => {} | 648 | _ => {} |
649 | } | 649 | } |