diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-03-17 08:12:34 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-03-17 08:12:34 +0000 |
commit | f7fbea509f1e5f840e715c912ee38aa997d1bfbc (patch) | |
tree | 2b4932678fc83624c278ca93cdf0f1d3a28346c2 /crates/ide_completion/src | |
parent | 6fcb5d772f16af0d1f62dad55fbde75072fb9e89 (diff) | |
parent | ff5f90d8ae2da8e4856d5c78f55e5cd02b178325 (diff) |
Merge #8063
8063: couple clippy::complexity fixes r=matklad a=matthiaskrgr
avoid redundant `.into()` calls to convert T into identical T (`let x: String = String::from("hello").into();`)
use `if let Some(x)` instead of `.is_some()` + `.unwrap()`
don't clone Copy types
remove redundant wrapped ?s: `Some(Some(3)?)` can just be `Some(3)`
use `.map(|x| y)` instead of `and_then(|x| Some(y)` on `Option`s
Co-authored-by: Matthias Krüger <[email protected]>
Diffstat (limited to 'crates/ide_completion/src')
-rw-r--r-- | crates/ide_completion/src/completions.rs | 2 | ||||
-rw-r--r-- | crates/ide_completion/src/completions/pattern.rs | 4 | ||||
-rw-r--r-- | crates/ide_completion/src/completions/postfix/format_like.rs | 2 | ||||
-rw-r--r-- | crates/ide_completion/src/render.rs | 2 |
4 files changed, 5 insertions, 5 deletions
diff --git a/crates/ide_completion/src/completions.rs b/crates/ide_completion/src/completions.rs index 3b582ed07..09882c4f3 100644 --- a/crates/ide_completion/src/completions.rs +++ b/crates/ide_completion/src/completions.rs | |||
@@ -56,7 +56,7 @@ impl Builder { | |||
56 | 56 | ||
57 | impl Completions { | 57 | impl Completions { |
58 | pub(crate) fn add(&mut self, item: CompletionItem) { | 58 | pub(crate) fn add(&mut self, item: CompletionItem) { |
59 | self.buf.push(item.into()) | 59 | self.buf.push(item) |
60 | } | 60 | } |
61 | 61 | ||
62 | pub(crate) fn add_all<I>(&mut self, items: I) | 62 | pub(crate) fn add_all<I>(&mut self, items: I) |
diff --git a/crates/ide_completion/src/completions/pattern.rs b/crates/ide_completion/src/completions/pattern.rs index 46cef58f0..476eecff0 100644 --- a/crates/ide_completion/src/completions/pattern.rs +++ b/crates/ide_completion/src/completions/pattern.rs | |||
@@ -26,11 +26,11 @@ pub(crate) fn complete_pattern(acc: &mut Completions, ctx: &CompletionContext) { | |||
26 | let add_resolution = match &res { | 26 | let add_resolution = match &res { |
27 | hir::ScopeDef::ModuleDef(def) => match def { | 27 | hir::ScopeDef::ModuleDef(def) => match def { |
28 | hir::ModuleDef::Adt(hir::Adt::Struct(strukt)) => { | 28 | hir::ModuleDef::Adt(hir::Adt::Struct(strukt)) => { |
29 | acc.add_struct_pat(ctx, strukt.clone(), Some(name.clone())); | 29 | acc.add_struct_pat(ctx, *strukt, Some(name.clone())); |
30 | true | 30 | true |
31 | } | 31 | } |
32 | hir::ModuleDef::Variant(variant) if !ctx.is_irrefutable_pat_binding => { | 32 | hir::ModuleDef::Variant(variant) if !ctx.is_irrefutable_pat_binding => { |
33 | acc.add_variant_pat(ctx, variant.clone(), Some(name.clone())); | 33 | acc.add_variant_pat(ctx, *variant, Some(name.clone())); |
34 | true | 34 | true |
35 | } | 35 | } |
36 | hir::ModuleDef::Adt(hir::Adt::Enum(..)) | 36 | hir::ModuleDef::Adt(hir::Adt::Enum(..)) |
diff --git a/crates/ide_completion/src/completions/postfix/format_like.rs b/crates/ide_completion/src/completions/postfix/format_like.rs index cee4eec10..3f1c6730b 100644 --- a/crates/ide_completion/src/completions/postfix/format_like.rs +++ b/crates/ide_completion/src/completions/postfix/format_like.rs | |||
@@ -89,7 +89,7 @@ enum State { | |||
89 | impl FormatStrParser { | 89 | impl FormatStrParser { |
90 | pub(crate) fn new(input: String) -> Self { | 90 | pub(crate) fn new(input: String) -> Self { |
91 | Self { | 91 | Self { |
92 | input: input.into(), | 92 | input: input, |
93 | output: String::new(), | 93 | output: String::new(), |
94 | extracted_expressions: Vec::new(), | 94 | extracted_expressions: Vec::new(), |
95 | state: State::NotExpr, | 95 | state: State::NotExpr, |
diff --git a/crates/ide_completion/src/render.rs b/crates/ide_completion/src/render.rs index 4e4923e0d..12921e12b 100644 --- a/crates/ide_completion/src/render.rs +++ b/crates/ide_completion/src/render.rs | |||
@@ -81,7 +81,7 @@ impl<'a> RenderContext<'a> { | |||
81 | } | 81 | } |
82 | 82 | ||
83 | fn snippet_cap(&self) -> Option<SnippetCap> { | 83 | fn snippet_cap(&self) -> Option<SnippetCap> { |
84 | self.completion.config.snippet_cap.clone() | 84 | self.completion.config.snippet_cap |
85 | } | 85 | } |
86 | 86 | ||
87 | fn db(&self) -> &'a RootDatabase { | 87 | fn db(&self) -> &'a RootDatabase { |