From c9b4ac5be4daaabc062ab1ee663eba8594750003 Mon Sep 17 00:00:00 2001 From: Maan2003 Date: Sun, 13 Jun 2021 09:24:16 +0530 Subject: clippy::redudant_borrow --- crates/mbe/src/expander/matcher.rs | 20 ++++++++++---------- crates/mbe/src/expander/transcriber.rs | 8 ++++---- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'crates/mbe/src/expander') 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 { /// Matching errors are added to the `Match`. pub(super) fn match_(pattern: &MetaTemplate, input: &tt::Subtree) -> Match { - let mut res = match_loop(pattern, &input); + let mut res = match_loop(pattern, input); res.bound_count = count(res.bindings.bindings()); return res; @@ -202,7 +202,7 @@ impl BindingsBuilder { } fn push_nested(&mut self, parent: &mut BindingsIdx, child: &BindingsIdx) { - let BindingsIdx(idx, nidx) = self.copy(&child); + let BindingsIdx(idx, nidx) = self.copy(child); self.nodes[parent.0].push(LinkNode::Node(Rc::new(BindingKind::Nested(idx, nidx)))); } @@ -221,7 +221,7 @@ impl BindingsBuilder { fn build_inner(&self, bindings: &mut Bindings, link_nodes: &[LinkNode>]) { let mut nodes = Vec::new(); - self.collect_nodes(&link_nodes, &mut nodes); + self.collect_nodes(link_nodes, &mut nodes); for cmd in nodes { match &**cmd { @@ -282,7 +282,7 @@ impl BindingsBuilder { nested_refs.into_iter().for_each(|iter| { let mut child_bindings = Bindings::default(); - self.build_inner(&mut child_bindings, &iter); + self.build_inner(&mut child_bindings, iter); nested.push(child_bindings) }) } @@ -417,7 +417,7 @@ fn match_loop_inner<'t>( let sep_len = item.sep.as_ref().map_or(0, Separator::tt_count); if item.sep.is_some() && sep_idx != sep_len { let sep = item.sep.as_ref().unwrap(); - if src.clone().expect_separator(&sep, sep_idx) { + if src.clone().expect_separator(sep, sep_idx) { item.dot.next(); item.sep_parsed = Some(sep_idx + 1); try_push!(next_items, item); @@ -487,7 +487,7 @@ fn match_loop_inner<'t>( item.meta_result = Some((fork, match_res)); try_push!(bb_items, item); } else { - bindings_builder.push_optional(&mut item.bindings, &name); + bindings_builder.push_optional(&mut item.bindings, name); item.dot.next(); cur_items.push(item); } @@ -495,7 +495,7 @@ fn match_loop_inner<'t>( Some(err) => { res.add_err(err); if let Some(fragment) = match_res.value { - bindings_builder.push_fragment(&mut item.bindings, &name, fragment); + bindings_builder.push_fragment(&mut item.bindings, name, fragment); } item.is_error = true; error_items.push(item); @@ -504,7 +504,7 @@ fn match_loop_inner<'t>( } } OpDelimited::Op(Op::Leaf(leaf)) => { - if let Err(err) = match_leaf(&leaf, &mut src.clone()) { + if let Err(err) = match_leaf(leaf, &mut src.clone()) { res.add_err(err); item.is_error = true; } else { @@ -640,10 +640,10 @@ fn match_loop(pattern: &MetaTemplate, src: &tt::Subtree) -> Match { let (iter, match_res) = item.meta_result.take().unwrap(); match match_res.value { Some(fragment) => { - bindings_builder.push_fragment(&mut item.bindings, &name, fragment); + bindings_builder.push_fragment(&mut item.bindings, name, fragment); } None if match_res.err.is_none() => { - bindings_builder.push_optional(&mut item.bindings, &name); + bindings_builder.push_optional(&mut item.bindings, name); } _ => {} } diff --git a/crates/mbe/src/expander/transcriber.rs b/crates/mbe/src/expander/transcriber.rs index dd7fa97d7..9a9c1a467 100644 --- a/crates/mbe/src/expander/transcriber.rs +++ b/crates/mbe/src/expander/transcriber.rs @@ -55,7 +55,7 @@ pub(super) fn transcribe( template: &MetaTemplate, bindings: &Bindings, ) -> ExpandResult { - let mut ctx = ExpandCtx { bindings: &bindings, nesting: Vec::new() }; + let mut ctx = ExpandCtx { bindings: bindings, nesting: Vec::new() }; let mut arena: Vec = Vec::new(); expand_subtree(&mut ctx, template, None, &mut arena) } @@ -91,12 +91,12 @@ fn expand_subtree( Op::Leaf(tt) => arena.push(tt.clone().into()), Op::Subtree { tokens, delimiter } => { let ExpandResult { value: tt, err: e } = - expand_subtree(ctx, &tokens, *delimiter, arena); + expand_subtree(ctx, tokens, *delimiter, arena); err = err.or(e); arena.push(tt.into()); } Op::Var { name, id, .. } => { - let ExpandResult { value: fragment, err: e } = expand_var(ctx, &name, *id); + let ExpandResult { value: fragment, err: e } = expand_var(ctx, name, *id); err = err.or(e); push_fragment(arena, fragment); } @@ -141,7 +141,7 @@ fn expand_var(ctx: &mut ExpandCtx, v: &SmolStr, id: tt::TokenId) -> ExpandResult .into(); ExpandResult::ok(Fragment::Tokens(tt)) } else { - ctx.bindings.get(&v, &mut ctx.nesting).map_or_else( + ctx.bindings.get(v, &mut ctx.nesting).map_or_else( |e| ExpandResult { value: Fragment::Tokens(tt::TokenTree::empty()), err: Some(e) }, |b| ExpandResult::ok(b.clone()), ) -- cgit v1.2.3