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_completion/src/completions/dot.rs | 2 +- crates/ide_completion/src/completions/postfix.rs | 20 ++++++++++---------- .../src/completions/postfix/format_like.rs | 2 +- .../ide_completion/src/completions/qualified_path.rs | 2 +- crates/ide_completion/src/context.rs | 2 +- crates/ide_completion/src/patterns.rs | 6 +++--- crates/ide_completion/src/render.rs | 2 +- crates/ide_completion/src/render/pattern.rs | 6 +++--- 8 files changed, 21 insertions(+), 21 deletions(-) (limited to 'crates/ide_completion/src') diff --git a/crates/ide_completion/src/completions/dot.rs b/crates/ide_completion/src/completions/dot.rs index 8ad57a069..9552875c1 100644 --- a/crates/ide_completion/src/completions/dot.rs +++ b/crates/ide_completion/src/completions/dot.rs @@ -13,7 +13,7 @@ pub(crate) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) { _ => return complete_undotted_self(acc, ctx), }; - let receiver_ty = match ctx.sema.type_of_expr(&dot_receiver) { + let receiver_ty = match ctx.sema.type_of_expr(dot_receiver) { Some(ty) => ty, _ => return, }; diff --git a/crates/ide_completion/src/completions/postfix.rs b/crates/ide_completion/src/completions/postfix.rs index 86eb21714..9f98b21be 100644 --- a/crates/ide_completion/src/completions/postfix.rs +++ b/crates/ide_completion/src/completions/postfix.rs @@ -34,7 +34,7 @@ pub(crate) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) { let receiver_text = get_receiver_text(dot_receiver, receiver_is_ambiguous_float_literal); - let receiver_ty = match ctx.sema.type_of_expr(&dot_receiver) { + let receiver_ty = match ctx.sema.type_of_expr(dot_receiver) { Some(it) => it, None => return, }; @@ -50,7 +50,7 @@ pub(crate) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) { postfix_snippet( ctx, cap, - &dot_receiver, + dot_receiver, "ifl", "if let Ok {}", &format!("if let Ok($1) = {} {{\n $0\n}}", receiver_text), @@ -60,7 +60,7 @@ pub(crate) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) { postfix_snippet( ctx, cap, - &dot_receiver, + dot_receiver, "while", "while let Ok {}", &format!("while let Ok($1) = {} {{\n $0\n}}", receiver_text), @@ -71,7 +71,7 @@ pub(crate) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) { postfix_snippet( ctx, cap, - &dot_receiver, + dot_receiver, "ifl", "if let Some {}", &format!("if let Some($1) = {} {{\n $0\n}}", receiver_text), @@ -81,7 +81,7 @@ pub(crate) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) { postfix_snippet( ctx, cap, - &dot_receiver, + dot_receiver, "while", "while let Some {}", &format!("while let Some($1) = {} {{\n $0\n}}", receiver_text), @@ -93,7 +93,7 @@ pub(crate) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) { postfix_snippet( ctx, cap, - &dot_receiver, + dot_receiver, "if", "if expr {}", &format!("if {} {{\n $0\n}}", receiver_text), @@ -102,22 +102,22 @@ pub(crate) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) { postfix_snippet( ctx, cap, - &dot_receiver, + dot_receiver, "while", "while expr {}", &format!("while {} {{\n $0\n}}", receiver_text), ) .add_to(acc); - postfix_snippet(ctx, cap, &dot_receiver, "not", "!expr", &format!("!{}", receiver_text)) + postfix_snippet(ctx, cap, dot_receiver, "not", "!expr", &format!("!{}", receiver_text)) .add_to(acc); } - postfix_snippet(ctx, cap, &dot_receiver, "ref", "&expr", &format!("&{}", receiver_text)) + postfix_snippet(ctx, cap, dot_receiver, "ref", "&expr", &format!("&{}", receiver_text)) .add_to(acc); postfix_snippet( ctx, cap, - &dot_receiver, + dot_receiver, "refm", "&mut expr", &format!("&mut {}", receiver_text), diff --git a/crates/ide_completion/src/completions/postfix/format_like.rs b/crates/ide_completion/src/completions/postfix/format_like.rs index 9ebe1dcc0..f619f8b52 100644 --- a/crates/ide_completion/src/completions/postfix/format_like.rs +++ b/crates/ide_completion/src/completions/postfix/format_like.rs @@ -53,7 +53,7 @@ pub(crate) fn add_format_like_completions( for (label, macro_name) in KINDS { let snippet = parser.into_suggestion(macro_name); - postfix_snippet(ctx, cap, &dot_receiver, label, macro_name, &snippet).add_to(acc); + postfix_snippet(ctx, cap, dot_receiver, label, macro_name, &snippet).add_to(acc); } } } diff --git a/crates/ide_completion/src/completions/qualified_path.rs b/crates/ide_completion/src/completions/qualified_path.rs index 58d4dd9ee..6083537b7 100644 --- a/crates/ide_completion/src/completions/qualified_path.rs +++ b/crates/ide_completion/src/completions/qualified_path.rs @@ -15,7 +15,7 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon None => return, }; - let resolution = match ctx.sema.resolve_path(&path) { + let resolution = match ctx.sema.resolve_path(path) { Some(res) => res, None => return, }; diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs index 2c2a4aa6b..e4abe2742 100644 --- a/crates/ide_completion/src/context.rs +++ b/crates/ide_completion/src/context.rs @@ -467,7 +467,7 @@ impl<'a> CompletionContext<'a> { self.expected_type = expected_type; self.expected_name = expected_name; - let name_like = match find_node_at_offset(&&file_with_fake_ident, offset) { + let name_like = match find_node_at_offset(&file_with_fake_ident, offset) { Some(it) => it, None => return, }; diff --git a/crates/ide_completion/src/patterns.rs b/crates/ide_completion/src/patterns.rs index 81d7a1a1d..c567ac63d 100644 --- a/crates/ide_completion/src/patterns.rs +++ b/crates/ide_completion/src/patterns.rs @@ -115,12 +115,12 @@ pub(crate) fn determine_location( ) -> Option { let node = match name_like { ast::NameLike::NameRef(name_ref) => { - if ast::RecordExprField::for_field_name(&name_ref).is_some() { + if ast::RecordExprField::for_field_name(name_ref).is_some() { return sema .find_node_at_offset_with_macros(original_file, offset) .map(ImmediateLocation::RecordExpr); } - if ast::RecordPatField::for_field_name_ref(&name_ref).is_some() { + if ast::RecordPatField::for_field_name_ref(name_ref).is_some() { return sema .find_node_at_offset_with_macros(original_file, offset) .map(ImmediateLocation::RecordPat); @@ -128,7 +128,7 @@ pub(crate) fn determine_location( maximize_name_ref(name_ref) } ast::NameLike::Name(name) => { - if ast::RecordPatField::for_field_name(&name).is_some() { + if ast::RecordPatField::for_field_name(name).is_some() { return sema .find_node_at_offset_with_macros(original_file, offset) .map(ImmediateLocation::RecordPat); diff --git a/crates/ide_completion/src/render.rs b/crates/ide_completion/src/render.rs index d3db55c35..a55081631 100644 --- a/crates/ide_completion/src/render.rs +++ b/crates/ide_completion/src/render.rs @@ -86,7 +86,7 @@ impl<'a> RenderContext<'a> { } fn db(&self) -> &'a RootDatabase { - &self.completion.db + self.completion.db } fn source_range(&self) -> TextRange { diff --git a/crates/ide_completion/src/render/pattern.rs b/crates/ide_completion/src/render/pattern.rs index b4e80f424..3717a0409 100644 --- a/crates/ide_completion/src/render/pattern.rs +++ b/crates/ide_completion/src/render/pattern.rs @@ -75,10 +75,10 @@ fn render_pat( ) -> Option { let mut pat = match kind { StructKind::Tuple if ctx.snippet_cap().is_some() => { - render_tuple_as_pat(&fields, &name, fields_omitted) + render_tuple_as_pat(fields, name, fields_omitted) } StructKind::Record => { - render_record_as_pat(ctx.db(), ctx.snippet_cap(), &fields, &name, fields_omitted) + render_record_as_pat(ctx.db(), ctx.snippet_cap(), fields, name, fields_omitted) } _ => return None, }; @@ -86,7 +86,7 @@ fn render_pat( if ctx.completion.is_param { pat.push(':'); pat.push(' '); - pat.push_str(&name); + pat.push_str(name); } if ctx.snippet_cap().is_some() { pat.push_str("$0"); -- cgit v1.2.3