Skip to content

Commit 1864147

Browse files
bors[bot]Veykril
andauthored
Merge #9666
9666: minor: Fix some clippy lints in ide_completion r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <[email protected]>
2 parents 4d457e2 + 9485d6e commit 1864147

File tree

10 files changed

+34
-41
lines changed

10 files changed

+34
-41
lines changed

crates/ide_completion/src/completions/attribute/cfg.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub(crate) fn complete_cfg(acc: &mut Completions, ctx: &CompletionContext) {
3232
Some("target_vendor") => KNOWN_VENDOR.iter().for_each(add_completion),
3333
Some("target_endian") => ["little", "big"].iter().for_each(add_completion),
3434
Some(name) => {
35-
ctx.krate.map(|krate| {
35+
if let Some(krate) = ctx.krate {
3636
krate.potential_cfg(ctx.db).get_cfg_values(&name).iter().for_each(|s| {
3737
let mut item = CompletionItem::new(
3838
CompletionKind::Attribute,
@@ -43,10 +43,10 @@ pub(crate) fn complete_cfg(acc: &mut Completions, ctx: &CompletionContext) {
4343

4444
acc.add(item.build());
4545
})
46-
});
46+
};
4747
}
4848
None => {
49-
ctx.krate.map(|krate| {
49+
if let Some(krate) = ctx.krate {
5050
krate.potential_cfg(ctx.db).get_cfg_keys().iter().for_each(|s| {
5151
let item = CompletionItem::new(
5252
CompletionKind::Attribute,
@@ -55,12 +55,12 @@ pub(crate) fn complete_cfg(acc: &mut Completions, ctx: &CompletionContext) {
5555
);
5656
acc.add(item.build());
5757
})
58-
});
58+
}
5959
}
6060
};
6161
}
6262

63-
const KNOWN_ARCH: [&'static str; 19] = [
63+
const KNOWN_ARCH: [&str; 19] = [
6464
"aarch64",
6565
"arm",
6666
"avr",
@@ -82,10 +82,9 @@ const KNOWN_ARCH: [&'static str; 19] = [
8282
"x86_64",
8383
];
8484

85-
const KNOWN_ENV: [&'static str; 7] =
86-
["eabihf", "gnu", "gnueabihf", "msvc", "relibc", "sgx", "uclibc"];
85+
const KNOWN_ENV: [&str; 7] = ["eabihf", "gnu", "gnueabihf", "msvc", "relibc", "sgx", "uclibc"];
8786

88-
const KNOWN_OS: [&'static str; 20] = [
87+
const KNOWN_OS: [&str; 20] = [
8988
"cuda",
9089
"dragonfly",
9190
"emscripten",
@@ -108,5 +107,5 @@ const KNOWN_OS: [&'static str; 20] = [
108107
"windows",
109108
];
110109

111-
const KNOWN_VENDOR: [&'static str; 8] =
110+
const KNOWN_VENDOR: [&str; 8] =
112111
["apple", "fortanix", "nvidia", "pc", "sony", "unknown", "wrs", "uwp"];

crates/ide_completion/src/completions/attribute/lint.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ pub(super) fn complete_lint(
1515
lints_completions: &[Lint],
1616
) {
1717
if let Some(existing_lints) = super::parse_comma_sep_input(derive_input) {
18-
for lint_completion in lints_completions
19-
.into_iter()
20-
.filter(|completion| !existing_lints.contains(completion.label))
18+
for lint_completion in
19+
lints_completions.iter().filter(|completion| !existing_lints.contains(completion.label))
2120
{
2221
let mut item = CompletionItem::new(
2322
CompletionKind::Attribute,

crates/ide_completion/src/completions/postfix.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,8 @@ fn postfix_snippet(
322322
let mut item = CompletionItem::new(CompletionKind::Postfix, ctx.source_range(), label);
323323
item.detail(detail).kind(CompletionItemKind::Snippet).snippet_edit(cap, edit);
324324
if ctx.original_token.text() == label {
325-
let mut relevance = CompletionRelevance::default();
326-
relevance.exact_postfix_snippet_match = true;
325+
let relevance =
326+
CompletionRelevance { exact_postfix_snippet_match: true, ..Default::default() };
327327
item.set_relevance(relevance);
328328
}
329329

crates/ide_completion/src/completions/postfix/format_like.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub(crate) fn add_format_like_completions(
5151

5252
if parser.parse().is_ok() {
5353
for (label, macro_name) in KINDS {
54-
let snippet = parser.into_suggestion(macro_name);
54+
let snippet = parser.to_suggestion(macro_name);
5555

5656
postfix_snippet(ctx, cap, dot_receiver, label, macro_name, &snippet).add_to(acc);
5757
}
@@ -201,7 +201,7 @@ impl FormatStrParser {
201201
Ok(())
202202
}
203203

204-
pub(crate) fn into_suggestion(&self, macro_name: &str) -> String {
204+
pub(crate) fn to_suggestion(&self, macro_name: &str) -> String {
205205
assert!(self.parsed, "Attempt to get a suggestion from not parsed expression");
206206

207207
let expressions_as_string = self.extracted_expressions.join(", ");
@@ -283,7 +283,7 @@ mod tests {
283283
let mut parser = FormatStrParser::new((*input).to_owned());
284284
parser.parse().expect("Parsing must succeed");
285285

286-
assert_eq!(&parser.into_suggestion(*kind), output);
286+
assert_eq!(&parser.to_suggestion(*kind), output);
287287
}
288288
}
289289
}

crates/ide_completion/src/render/const_.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ use crate::{
1212
render::RenderContext,
1313
};
1414

15-
pub(crate) fn render_const<'a>(
16-
ctx: RenderContext<'a>,
17-
const_: hir::Const,
18-
) -> Option<CompletionItem> {
15+
pub(crate) fn render_const(ctx: RenderContext<'_>, const_: hir::Const) -> Option<CompletionItem> {
1916
ConstRender::new(ctx, const_)?.render()
2017
}
2118

@@ -50,7 +47,7 @@ impl<'a> ConstRender<'a> {
5047
if let Some(actm) = self.const_.as_assoc_item(db) {
5148
if let Some(trt) = actm.containing_trait_or_trait_impl(db) {
5249
item.trait_name(trt.name(db).to_string());
53-
item.insert_text(name.clone());
50+
item.insert_text(name);
5451
}
5552
}
5653

crates/ide_completion/src/render/enum_variant.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use crate::{
1212
CompletionRelevance,
1313
};
1414

15-
pub(crate) fn render_variant<'a>(
16-
ctx: RenderContext<'a>,
15+
pub(crate) fn render_variant(
16+
ctx: RenderContext<'_>,
1717
import_to_add: Option<ImportEdit>,
1818
local_name: Option<hir::Name>,
1919
variant: hir::Variant,

crates/ide_completion/src/render/function.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ use crate::{
1313
},
1414
};
1515

16-
pub(crate) fn render_fn<'a>(
17-
ctx: RenderContext<'a>,
16+
pub(crate) fn render_fn(
17+
ctx: RenderContext<'_>,
1818
import_to_add: Option<ImportEdit>,
1919
local_name: Option<hir::Name>,
2020
fn_: hir::Function,
@@ -23,8 +23,8 @@ pub(crate) fn render_fn<'a>(
2323
Some(FunctionRender::new(ctx, None, local_name, fn_, false)?.render(import_to_add))
2424
}
2525

26-
pub(crate) fn render_method<'a>(
27-
ctx: RenderContext<'a>,
26+
pub(crate) fn render_method(
27+
ctx: RenderContext<'_>,
2828
import_to_add: Option<ImportEdit>,
2929
receiver: Option<hir::Name>,
3030
local_name: Option<hir::Name>,

crates/ide_completion/src/render/macro_.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use crate::{
1010
render::RenderContext,
1111
};
1212

13-
pub(crate) fn render_macro<'a>(
14-
ctx: RenderContext<'a>,
13+
pub(crate) fn render_macro(
14+
ctx: RenderContext<'_>,
1515
import_to_add: Option<ImportEdit>,
1616
name: hir::Name,
1717
macro_: hir::MacroDef,
@@ -76,12 +76,10 @@ impl<'a> MacroRender<'a> {
7676
fn label(&self) -> String {
7777
if self.needs_bang() && self.ctx.snippet_cap().is_some() {
7878
format!("{}!{}…{}", self.name, self.bra, self.ket)
79+
} else if self.macro_.kind() == hir::MacroKind::Derive {
80+
self.name.to_string()
7981
} else {
80-
if self.macro_.kind() == hir::MacroKind::Derive {
81-
self.name.to_string()
82-
} else {
83-
self.banged_name()
84-
}
82+
self.banged_name()
8583
}
8684
}
8785

crates/ide_completion/src/render/pattern.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ fn visible_fields(
139139
let module = ctx.completion.scope.module()?;
140140
let n_fields = fields.len();
141141
let fields = fields
142-
.into_iter()
142+
.iter()
143143
.filter(|field| field.is_visible_from(ctx.db(), module))
144144
.copied()
145145
.collect::<Vec<_>>();

crates/ide_completion/src/render/type_alias.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ use crate::{
1212
render::RenderContext,
1313
};
1414

15-
pub(crate) fn render_type_alias<'a>(
16-
ctx: RenderContext<'a>,
15+
pub(crate) fn render_type_alias(
16+
ctx: RenderContext<'_>,
1717
type_alias: hir::TypeAlias,
1818
) -> Option<CompletionItem> {
1919
TypeAliasRender::new(ctx, type_alias)?.render(false)
2020
}
2121

22-
pub(crate) fn render_type_alias_with_eq<'a>(
23-
ctx: RenderContext<'a>,
22+
pub(crate) fn render_type_alias_with_eq(
23+
ctx: RenderContext<'_>,
2424
type_alias: hir::TypeAlias,
2525
) -> Option<CompletionItem> {
2626
TypeAliasRender::new(ctx, type_alias)?.render(true)
@@ -63,7 +63,7 @@ impl<'a> TypeAliasRender<'a> {
6363
if let Some(actm) = self.type_alias.as_assoc_item(db) {
6464
if let Some(trt) = actm.containing_trait_or_trait_impl(db) {
6565
item.trait_name(trt.name(db).to_string());
66-
item.insert_text(name.clone());
66+
item.insert_text(name);
6767
}
6868
}
6969

0 commit comments

Comments
 (0)