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/ide_ssr/src/matching.rs | 6 +++--- crates/ide_ssr/src/replacing.rs | 10 +++++----- crates/ide_ssr/src/resolving.rs | 2 +- crates/ide_ssr/src/search.rs | 2 +- crates/ide_ssr/src/tests.rs | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) (limited to 'crates/ide_ssr/src') diff --git a/crates/ide_ssr/src/matching.rs b/crates/ide_ssr/src/matching.rs index b3072fb9f..fb92a0ccc 100644 --- a/crates/ide_ssr/src/matching.rs +++ b/crates/ide_ssr/src/matching.rs @@ -382,7 +382,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> { code: Option, ) -> Result<(), MatchFailed> { match (pattern, code) { - (Some(p), Some(c)) => self.attempt_match_node(phase, &p.syntax(), &c.syntax()), + (Some(p), Some(c)) => self.attempt_match_node(phase, p.syntax(), c.syntax()), (None, None) => Ok(()), (Some(p), None) => fail_match!("Pattern `{}` had nothing to match", p.syntax().text()), (None, Some(c)) => { @@ -478,7 +478,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> { if Some(first_token.text()) == next_pattern_token.as_deref() { if let Some(SyntaxElement::Node(p)) = pattern.next() { // We have a subtree that starts with the next token in our pattern. - self.attempt_match_token_tree(phase, &p, &n)?; + self.attempt_match_token_tree(phase, &p, n)?; break; } } @@ -609,7 +609,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> { expr: &ast::Expr, ) -> Result { use hir::HirDisplay; - let code_type = self.sema.type_of_expr(&expr).ok_or_else(|| { + let code_type = self.sema.type_of_expr(expr).ok_or_else(|| { match_error!("Failed to get receiver type for `{}`", expr.syntax().text()) })?; // Temporary needed to make the borrow checker happy. diff --git a/crates/ide_ssr/src/replacing.rs b/crates/ide_ssr/src/replacing.rs index c9ccc1961..9265af7c1 100644 --- a/crates/ide_ssr/src/replacing.rs +++ b/crates/ide_ssr/src/replacing.rs @@ -84,16 +84,16 @@ impl ReplacementRenderer<'_> { fn render_node_or_token(&mut self, node_or_token: &SyntaxElement) { match node_or_token { SyntaxElement::Token(token) => { - self.render_token(&token); + self.render_token(token); } SyntaxElement::Node(child_node) => { - self.render_node(&child_node); + self.render_node(child_node); } } } fn render_node(&mut self, node: &SyntaxNode) { - if let Some(mod_path) = self.match_info.rendered_template_paths.get(&node) { + if let Some(mod_path) = self.match_info.rendered_template_paths.get(node) { self.out.push_str(&mod_path.to_string()); // Emit everything except for the segment's name-ref, since we already effectively // emitted that as part of `mod_path`. @@ -107,12 +107,12 @@ impl ReplacementRenderer<'_> { } } } else { - self.render_node_children(&node); + self.render_node_children(node); } } fn render_token(&mut self, token: &SyntaxToken) { - if let Some(placeholder) = self.rule.get_placeholder(&token) { + if let Some(placeholder) = self.rule.get_placeholder(token) { if let Some(placeholder_value) = self.match_info.placeholder_values.get(&placeholder.ident) { diff --git a/crates/ide_ssr/src/resolving.rs b/crates/ide_ssr/src/resolving.rs index 541da4122..a66a7a4a8 100644 --- a/crates/ide_ssr/src/resolving.rs +++ b/crates/ide_ssr/src/resolving.rs @@ -211,7 +211,7 @@ impl<'db> ResolutionScope<'db> { // First try resolving the whole path. This will work for things like // `std::collections::HashMap`, but will fail for things like // `std::collections::HashMap::new`. - if let Some(resolution) = self.scope.speculative_resolve(&path) { + if let Some(resolution) = self.scope.speculative_resolve(path) { return Some(resolution); } // Resolution failed, try resolving the qualifier (e.g. `std::collections::HashMap` and if diff --git a/crates/ide_ssr/src/search.rs b/crates/ide_ssr/src/search.rs index 28cef742c..f2056919e 100644 --- a/crates/ide_ssr/src/search.rs +++ b/crates/ide_ssr/src/search.rs @@ -173,7 +173,7 @@ impl<'db> MatchFinder<'db> { if !is_search_permitted(code) { return; } - self.try_add_match(rule, &code, restrict_range, matches_out); + self.try_add_match(rule, code, restrict_range, matches_out); // If we've got a macro call, we already tried matching it pre-expansion, which is the only // way to match the whole macro, now try expanding it and matching the expansion. if let Some(macro_call) = ast::MacroCall::cast(code.clone()) { diff --git a/crates/ide_ssr/src/tests.rs b/crates/ide_ssr/src/tests.rs index 1d8565dc0..5dd0d600f 100644 --- a/crates/ide_ssr/src/tests.rs +++ b/crates/ide_ssr/src/tests.rs @@ -129,7 +129,7 @@ fn assert_matches(pattern: &str, code: &str, expected: &[&str]) { let matched_strings: Vec = match_finder.matches().flattened().matches.iter().map(|m| m.matched_text()).collect(); if matched_strings != expected && !expected.is_empty() { - print_match_debug_info(&match_finder, position.file_id, &expected[0]); + print_match_debug_info(&match_finder, position.file_id, expected[0]); } assert_eq!(matched_strings, expected); } -- cgit v1.2.3