Unnamed repository; edit this file 'description' to name the repository.
ide-completion: Fix warnings about clippy `str_to_string` rule
Tetsuharu Ohzeki 2024-02-09
parent 395708d · commit f4a4b66
-rw-r--r--crates/ide-completion/src/completions/extern_crate.rs4
-rw-r--r--crates/ide-completion/src/completions/postfix.rs2
-rw-r--r--crates/ide-completion/src/context.rs2
-rw-r--r--crates/ide-completion/src/item.rs2
-rw-r--r--crates/ide-completion/src/render.rs6
-rw-r--r--crates/ide-completion/src/render/function.rs4
-rw-r--r--crates/ide-completion/src/render/pattern.rs2
-rw-r--r--crates/ide-completion/src/render/variant.rs4
8 files changed, 13 insertions, 13 deletions
diff --git a/crates/ide-completion/src/completions/extern_crate.rs b/crates/ide-completion/src/completions/extern_crate.rs
index f9cde44667..b67d82c20d 100644
--- a/crates/ide-completion/src/completions/extern_crate.rs
+++ b/crates/ide-completion/src/completions/extern_crate.rs
@@ -46,7 +46,7 @@ mod other_mod {}
let completion_list = completion_list_no_kw(case);
- assert_eq!("md other_crate_a\n".to_string(), completion_list);
+ assert_eq!("md other_crate_a\n".to_owned(), completion_list);
}
#[test]
@@ -66,6 +66,6 @@ mod other_mod {}
let completion_list = completion_list_no_kw(case);
- assert_eq!("md other_crate_a\n".to_string(), completion_list);
+ assert_eq!("md other_crate_a\n".to_owned(), completion_list);
}
}
diff --git a/crates/ide-completion/src/completions/postfix.rs b/crates/ide-completion/src/completions/postfix.rs
index d34d2e7e98..72c0885e92 100644
--- a/crates/ide-completion/src/completions/postfix.rs
+++ b/crates/ide-completion/src/completions/postfix.rs
@@ -326,7 +326,7 @@ fn build_postfix_snippet_builder<'ctx>(
delete_range: TextRange,
) -> impl Fn(&str, &str, &str) -> Builder + 'ctx {
move |label, detail, snippet| {
- let edit = TextEdit::replace(delete_range, snippet.to_string());
+ let edit = TextEdit::replace(delete_range, snippet.to_owned());
let mut item =
CompletionItem::new(CompletionItemKind::Snippet, ctx.source_range(), label);
item.detail(detail).snippet_edit(cap, edit);
diff --git a/crates/ide-completion/src/context.rs b/crates/ide-completion/src/context.rs
index e07937787c..2a0004f60b 100644
--- a/crates/ide-completion/src/context.rs
+++ b/crates/ide-completion/src/context.rs
@@ -665,7 +665,7 @@ impl<'a> CompletionContext<'a> {
// actual completion.
let file_with_fake_ident = {
let parse = db.parse(file_id);
- let edit = Indel::insert(offset, COMPLETION_MARKER.to_string());
+ let edit = Indel::insert(offset, COMPLETION_MARKER.to_owned());
parse.reparse(&edit).tree()
};
diff --git a/crates/ide-completion/src/item.rs b/crates/ide-completion/src/item.rs
index bcf169f465..8552a20392 100644
--- a/crates/ide-completion/src/item.rs
+++ b/crates/ide-completion/src/item.rs
@@ -553,7 +553,7 @@ impl Builder {
self.detail = detail.map(Into::into);
if let Some(detail) = &self.detail {
if never!(detail.contains('\n'), "multiline detail:\n{}", detail) {
- self.detail = Some(detail.split('\n').next().unwrap().to_string());
+ self.detail = Some(detail.split('\n').next().unwrap().to_owned());
}
}
self
diff --git a/crates/ide-completion/src/render.rs b/crates/ide-completion/src/render.rs
index 5172829266..548466d8de 100644
--- a/crates/ide-completion/src/render.rs
+++ b/crates/ide-completion/src/render.rs
@@ -167,14 +167,14 @@ pub(crate) fn render_field(
if !expected_fn_type {
if let Some(receiver) = &dot_access.receiver {
if let Some(receiver) = ctx.completion.sema.original_ast_node(receiver.clone()) {
- builder.insert(receiver.syntax().text_range().start(), "(".to_string());
- builder.insert(ctx.source_range().end(), ")".to_string());
+ builder.insert(receiver.syntax().text_range().start(), "(".to_owned());
+ builder.insert(ctx.source_range().end(), ")".to_owned());
let is_parens_needed =
!matches!(dot_access.kind, DotAccessKind::Method { has_parens: true });
if is_parens_needed {
- builder.insert(ctx.source_range().end(), "()".to_string());
+ builder.insert(ctx.source_range().end(), "()".to_owned());
}
}
}
diff --git a/crates/ide-completion/src/render/function.rs b/crates/ide-completion/src/render/function.rs
index 4ae7ea861c..f3ac06c131 100644
--- a/crates/ide-completion/src/render/function.rs
+++ b/crates/ide-completion/src/render/function.rs
@@ -184,12 +184,12 @@ pub(super) fn add_call_parens<'b>(
}
None => {
let name = match param.ty().as_adt() {
- None => "_".to_string(),
+ None => "_".to_owned(),
Some(adt) => adt
.name(ctx.db)
.as_text()
.map(|s| to_lower_snake_case(s.as_str()))
- .unwrap_or_else(|| "_".to_string()),
+ .unwrap_or_else(|| "_".to_owned()),
};
f(&format_args!("${{{}:{name}}}", index + offset))
}
diff --git a/crates/ide-completion/src/render/pattern.rs b/crates/ide-completion/src/render/pattern.rs
index a5f851566c..c07966f7a7 100644
--- a/crates/ide-completion/src/render/pattern.rs
+++ b/crates/ide-completion/src/render/pattern.rs
@@ -140,7 +140,7 @@ fn render_pat(
StructKind::Record => {
render_record_as_pat(ctx.db(), ctx.snippet_cap(), fields, name, fields_omitted)
}
- StructKind::Unit => name.to_string(),
+ StructKind::Unit => name.to_owned(),
};
let needs_ascription = matches!(
diff --git a/crates/ide-completion/src/render/variant.rs b/crates/ide-completion/src/render/variant.rs
index a9a01a3a30..28238de455 100644
--- a/crates/ide-completion/src/render/variant.rs
+++ b/crates/ide-completion/src/render/variant.rs
@@ -23,7 +23,7 @@ pub(crate) fn render_record_lit(
path: &str,
) -> RenderedLiteral {
if snippet_cap.is_none() {
- return RenderedLiteral { literal: path.to_string(), detail: path.to_string() };
+ return RenderedLiteral { literal: path.to_owned(), detail: path.to_owned() };
}
let completions = fields.iter().enumerate().format_with(", ", |(idx, field), f| {
if snippet_cap.is_some() {
@@ -52,7 +52,7 @@ pub(crate) fn render_tuple_lit(
path: &str,
) -> RenderedLiteral {
if snippet_cap.is_none() {
- return RenderedLiteral { literal: path.to_string(), detail: path.to_string() };
+ return RenderedLiteral { literal: path.to_owned(), detail: path.to_owned() };
}
let completions = fields.iter().enumerate().format_with(", ", |(idx, _), f| {
if snippet_cap.is_some() {