ide-completion: Fix warnings about clippy str_to_string
rule
This commit is contained in:
parent
395708d5e0
commit
f4a4b6681b
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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()
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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))
|
||||
}
|
||||
|
@ -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!(
|
||||
|
@ -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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user