diff --git a/crates/ide_completion/src/completions/attribute/cfg.rs b/crates/ide_completion/src/completions/attribute/cfg.rs index 847e6529a1b..72b68f3b9f9 100644 --- a/crates/ide_completion/src/completions/attribute/cfg.rs +++ b/crates/ide_completion/src/completions/attribute/cfg.rs @@ -32,7 +32,7 @@ pub(crate) fn complete_cfg(acc: &mut Completions, ctx: &CompletionContext) { Some("target_vendor") => KNOWN_VENDOR.iter().for_each(add_completion), Some("target_endian") => ["little", "big"].iter().for_each(add_completion), Some(name) => { - ctx.krate.map(|krate| { + if let Some(krate) = ctx.krate { krate.potential_cfg(ctx.db).get_cfg_values(&name).iter().for_each(|s| { let mut item = CompletionItem::new( CompletionKind::Attribute, @@ -43,10 +43,10 @@ pub(crate) fn complete_cfg(acc: &mut Completions, ctx: &CompletionContext) { acc.add(item.build()); }) - }); + }; } None => { - ctx.krate.map(|krate| { + if let Some(krate) = ctx.krate { krate.potential_cfg(ctx.db).get_cfg_keys().iter().for_each(|s| { let item = CompletionItem::new( CompletionKind::Attribute, @@ -55,12 +55,12 @@ pub(crate) fn complete_cfg(acc: &mut Completions, ctx: &CompletionContext) { ); acc.add(item.build()); }) - }); + } } }; } -const KNOWN_ARCH: [&'static str; 19] = [ +const KNOWN_ARCH: [&str; 19] = [ "aarch64", "arm", "avr", @@ -82,10 +82,9 @@ pub(crate) fn complete_cfg(acc: &mut Completions, ctx: &CompletionContext) { "x86_64", ]; -const KNOWN_ENV: [&'static str; 7] = - ["eabihf", "gnu", "gnueabihf", "msvc", "relibc", "sgx", "uclibc"]; +const KNOWN_ENV: [&str; 7] = ["eabihf", "gnu", "gnueabihf", "msvc", "relibc", "sgx", "uclibc"]; -const KNOWN_OS: [&'static str; 20] = [ +const KNOWN_OS: [&str; 20] = [ "cuda", "dragonfly", "emscripten", @@ -108,5 +107,5 @@ pub(crate) fn complete_cfg(acc: &mut Completions, ctx: &CompletionContext) { "windows", ]; -const KNOWN_VENDOR: [&'static str; 8] = +const KNOWN_VENDOR: [&str; 8] = ["apple", "fortanix", "nvidia", "pc", "sony", "unknown", "wrs", "uwp"]; diff --git a/crates/ide_completion/src/completions/attribute/lint.rs b/crates/ide_completion/src/completions/attribute/lint.rs index bb7f4c8d3b3..8b17be09b1c 100644 --- a/crates/ide_completion/src/completions/attribute/lint.rs +++ b/crates/ide_completion/src/completions/attribute/lint.rs @@ -15,9 +15,8 @@ pub(super) fn complete_lint( lints_completions: &[Lint], ) { if let Some(existing_lints) = super::parse_comma_sep_input(derive_input) { - for lint_completion in lints_completions - .into_iter() - .filter(|completion| !existing_lints.contains(completion.label)) + for lint_completion in + lints_completions.iter().filter(|completion| !existing_lints.contains(completion.label)) { let mut item = CompletionItem::new( CompletionKind::Attribute, diff --git a/crates/ide_completion/src/completions/postfix.rs b/crates/ide_completion/src/completions/postfix.rs index 8aaaa104779..8ac54cc1b4a 100644 --- a/crates/ide_completion/src/completions/postfix.rs +++ b/crates/ide_completion/src/completions/postfix.rs @@ -322,8 +322,8 @@ fn postfix_snippet( let mut item = CompletionItem::new(CompletionKind::Postfix, ctx.source_range(), label); item.detail(detail).kind(CompletionItemKind::Snippet).snippet_edit(cap, edit); if ctx.original_token.text() == label { - let mut relevance = CompletionRelevance::default(); - relevance.exact_postfix_snippet_match = true; + let relevance = + CompletionRelevance { exact_postfix_snippet_match: true, ..Default::default() }; item.set_relevance(relevance); } diff --git a/crates/ide_completion/src/completions/postfix/format_like.rs b/crates/ide_completion/src/completions/postfix/format_like.rs index 2dc13c293a6..d4061203c71 100644 --- a/crates/ide_completion/src/completions/postfix/format_like.rs +++ b/crates/ide_completion/src/completions/postfix/format_like.rs @@ -51,7 +51,7 @@ pub(crate) fn add_format_like_completions( if parser.parse().is_ok() { for (label, macro_name) in KINDS { - let snippet = parser.into_suggestion(macro_name); + let snippet = parser.to_suggestion(macro_name); postfix_snippet(ctx, cap, dot_receiver, label, macro_name, &snippet).add_to(acc); } @@ -201,7 +201,7 @@ pub(crate) fn parse(&mut self) -> Result<(), ()> { Ok(()) } - pub(crate) fn into_suggestion(&self, macro_name: &str) -> String { + pub(crate) fn to_suggestion(&self, macro_name: &str) -> String { assert!(self.parsed, "Attempt to get a suggestion from not parsed expression"); let expressions_as_string = self.extracted_expressions.join(", "); @@ -283,7 +283,7 @@ fn test_into_suggestion() { let mut parser = FormatStrParser::new((*input).to_owned()); parser.parse().expect("Parsing must succeed"); - assert_eq!(&parser.into_suggestion(*kind), output); + assert_eq!(&parser.to_suggestion(*kind), output); } } } diff --git a/crates/ide_completion/src/render/const_.rs b/crates/ide_completion/src/render/const_.rs index 0a17d8023d8..4609f2e9675 100644 --- a/crates/ide_completion/src/render/const_.rs +++ b/crates/ide_completion/src/render/const_.rs @@ -12,10 +12,7 @@ render::RenderContext, }; -pub(crate) fn render_const<'a>( - ctx: RenderContext<'a>, - const_: hir::Const, -) -> Option { +pub(crate) fn render_const(ctx: RenderContext<'_>, const_: hir::Const) -> Option { ConstRender::new(ctx, const_)?.render() } @@ -50,7 +47,7 @@ fn render(self) -> Option { if let Some(actm) = self.const_.as_assoc_item(db) { if let Some(trt) = actm.containing_trait_or_trait_impl(db) { item.trait_name(trt.name(db).to_string()); - item.insert_text(name.clone()); + item.insert_text(name); } } diff --git a/crates/ide_completion/src/render/enum_variant.rs b/crates/ide_completion/src/render/enum_variant.rs index 91dc178f345..44a5ceb25ad 100644 --- a/crates/ide_completion/src/render/enum_variant.rs +++ b/crates/ide_completion/src/render/enum_variant.rs @@ -12,8 +12,8 @@ CompletionRelevance, }; -pub(crate) fn render_variant<'a>( - ctx: RenderContext<'a>, +pub(crate) fn render_variant( + ctx: RenderContext<'_>, import_to_add: Option, local_name: Option, variant: hir::Variant, diff --git a/crates/ide_completion/src/render/function.rs b/crates/ide_completion/src/render/function.rs index 5ad1c899eeb..87714def967 100644 --- a/crates/ide_completion/src/render/function.rs +++ b/crates/ide_completion/src/render/function.rs @@ -13,8 +13,8 @@ }, }; -pub(crate) fn render_fn<'a>( - ctx: RenderContext<'a>, +pub(crate) fn render_fn( + ctx: RenderContext<'_>, import_to_add: Option, local_name: Option, fn_: hir::Function, @@ -23,8 +23,8 @@ pub(crate) fn render_fn<'a>( Some(FunctionRender::new(ctx, None, local_name, fn_, false)?.render(import_to_add)) } -pub(crate) fn render_method<'a>( - ctx: RenderContext<'a>, +pub(crate) fn render_method( + ctx: RenderContext<'_>, import_to_add: Option, receiver: Option, local_name: Option, diff --git a/crates/ide_completion/src/render/macro_.rs b/crates/ide_completion/src/render/macro_.rs index 4d5179c4f95..80c05273ca3 100644 --- a/crates/ide_completion/src/render/macro_.rs +++ b/crates/ide_completion/src/render/macro_.rs @@ -10,8 +10,8 @@ render::RenderContext, }; -pub(crate) fn render_macro<'a>( - ctx: RenderContext<'a>, +pub(crate) fn render_macro( + ctx: RenderContext<'_>, import_to_add: Option, name: hir::Name, macro_: hir::MacroDef, @@ -76,12 +76,10 @@ fn needs_bang(&self) -> bool { fn label(&self) -> String { if self.needs_bang() && self.ctx.snippet_cap().is_some() { format!("{}!{}…{}", self.name, self.bra, self.ket) + } else if self.macro_.kind() == hir::MacroKind::Derive { + self.name.to_string() } else { - if self.macro_.kind() == hir::MacroKind::Derive { - self.name.to_string() - } else { - self.banged_name() - } + self.banged_name() } } diff --git a/crates/ide_completion/src/render/pattern.rs b/crates/ide_completion/src/render/pattern.rs index 3717a0409a9..17dd6662f5f 100644 --- a/crates/ide_completion/src/render/pattern.rs +++ b/crates/ide_completion/src/render/pattern.rs @@ -139,7 +139,7 @@ fn visible_fields( let module = ctx.completion.scope.module()?; let n_fields = fields.len(); let fields = fields - .into_iter() + .iter() .filter(|field| field.is_visible_from(ctx.db(), module)) .copied() .collect::>(); diff --git a/crates/ide_completion/src/render/type_alias.rs b/crates/ide_completion/src/render/type_alias.rs index 9549678b69e..6021448e784 100644 --- a/crates/ide_completion/src/render/type_alias.rs +++ b/crates/ide_completion/src/render/type_alias.rs @@ -12,15 +12,15 @@ render::RenderContext, }; -pub(crate) fn render_type_alias<'a>( - ctx: RenderContext<'a>, +pub(crate) fn render_type_alias( + ctx: RenderContext<'_>, type_alias: hir::TypeAlias, ) -> Option { TypeAliasRender::new(ctx, type_alias)?.render(false) } -pub(crate) fn render_type_alias_with_eq<'a>( - ctx: RenderContext<'a>, +pub(crate) fn render_type_alias_with_eq( + ctx: RenderContext<'_>, type_alias: hir::TypeAlias, ) -> Option { TypeAliasRender::new(ctx, type_alias)?.render(true) @@ -63,7 +63,7 @@ fn render(self, with_eq: bool) -> Option { if let Some(actm) = self.type_alias.as_assoc_item(db) { if let Some(trt) = actm.containing_trait_or_trait_impl(db) { item.trait_name(trt.name(db).to_string()); - item.insert_text(name.clone()); + item.insert_text(name); } }