Skip to content

Commit 80e6842

Browse files
ide-assists: Fix warnings about clippy str_to_string rule
1 parent b89a403 commit 80e6842

18 files changed

+25
-25
lines changed

crates/ide-assists/src/handlers/apply_demorgan.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pub(crate) fn apply_demorgan(acc: &mut Assists, ctx: &AssistContext<'_>) -> Opti
9696
let dm_lhs = demorganed.lhs()?;
9797

9898
acc.add_group(
99-
&GroupLabel("Apply De Morgan's law".to_string()),
99+
&GroupLabel("Apply De Morgan's law".to_owned()),
100100
AssistId("apply_demorgan", AssistKind::RefactorRewrite),
101101
"Apply De Morgan's law",
102102
op_range,
@@ -187,7 +187,7 @@ pub(crate) fn apply_demorgan_iterator(acc: &mut Assists, ctx: &AssistContext<'_>
187187
let op_range = method_call.syntax().text_range();
188188
let label = format!("Apply De Morgan's law to `Iterator::{}`", name.text().as_str());
189189
acc.add_group(
190-
&GroupLabel("Apply De Morgan's law".to_string()),
190+
&GroupLabel("Apply De Morgan's law".to_owned()),
191191
AssistId("apply_demorgan_iterator", AssistKind::RefactorRewrite),
192192
label,
193193
op_range,

crates/ide-assists/src/handlers/convert_comment_block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn block_to_line(acc: &mut Assists, comment: ast::Comment) -> Option<()> {
5757

5858
// Don't introduce trailing whitespace
5959
if line.is_empty() {
60-
line_prefix.to_string()
60+
line_prefix.to_owned()
6161
} else {
6262
format!("{line_prefix} {line}")
6363
}

crates/ide-assists/src/handlers/extract_function.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ fn make_function_name(semantics_scope: &hir::SemanticsScope<'_>) -> ast::NameRef
244244

245245
let default_name = "fun_name";
246246

247-
let mut name = default_name.to_string();
247+
let mut name = default_name.to_owned();
248248
let mut counter = 0;
249249
while names_in_scope.contains(&name) {
250250
counter += 1;
@@ -1949,7 +1949,7 @@ fn with_tail_expr(block: ast::BlockExpr, tail_expr: ast::Expr) -> ast::BlockExpr
19491949
}
19501950

19511951
fn format_type(ty: &hir::Type, ctx: &AssistContext<'_>, module: hir::Module) -> String {
1952-
ty.display_source_code(ctx.db(), module.into(), true).ok().unwrap_or_else(|| "_".to_string())
1952+
ty.display_source_code(ctx.db(), module.into(), true).ok().unwrap_or_else(|| "_".to_owned())
19531953
}
19541954

19551955
fn make_ty(ty: &hir::Type, ctx: &AssistContext<'_>, module: hir::Module) -> ast::Type {

crates/ide-assists/src/handlers/extract_variable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext<'_>) -> Op
115115
let trailing_ws = if prev_ws.is_some_and(|it| it.text().starts_with('\n')) {
116116
format!("\n{indent_to}")
117117
} else {
118-
" ".to_string()
118+
" ".to_owned()
119119
};
120120

121121
ted::insert_all_raw(

crates/ide-assists/src/handlers/generate_documentation_template.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,9 @@ fn arguments_from_params(param_list: &ast::ParamList) -> String {
416416
true => format!("&mut {name}"),
417417
false => name.to_string(),
418418
},
419-
None => "_".to_string(),
419+
None => "_".to_owned(),
420420
},
421-
_ => "_".to_string(),
421+
_ => "_".to_owned(),
422422
});
423423
args_iter.format(", ").to_string()
424424
}

crates/ide-assists/src/handlers/generate_enum_variant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ fn make_record_field_list(
162162
fn name_from_field(field: &ast::RecordExprField) -> ast::Name {
163163
let text = match field.name_ref() {
164164
Some(it) => it.to_string(),
165-
None => name_from_field_shorthand(field).unwrap_or("unknown".to_string()),
165+
None => name_from_field_shorthand(field).unwrap_or("unknown".to_owned()),
166166
};
167167
make::name(&text)
168168
}

crates/ide-assists/src/handlers/generate_function.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ fn get_adt_source(
202202
let file = ctx.sema.parse(range.file_id);
203203
let adt_source =
204204
ctx.sema.find_node_at_offset_with_macros(file.syntax(), range.range.start())?;
205-
find_struct_impl(ctx, &adt_source, &[fn_name.to_string()]).map(|impl_| (impl_, range.file_id))
205+
find_struct_impl(ctx, &adt_source, &[fn_name.to_owned()]).map(|impl_| (impl_, range.file_id))
206206
}
207207

208208
struct FunctionTemplate {
@@ -1007,7 +1007,7 @@ fn fn_arg_name(sema: &Semantics<'_, RootDatabase>, arg_expr: &ast::Expr) -> Stri
10071007
name
10081008
}
10091009
Some(name) => name,
1010-
None => "arg".to_string(),
1010+
None => "arg".to_owned(),
10111011
}
10121012
}
10131013

crates/ide-assists/src/handlers/generate_is_empty_from_len.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub(crate) fn generate_is_empty_from_len(acc: &mut Assists, ctx: &AssistContext<
7979
pub fn is_empty(&self) -> bool {
8080
self.len() == 0
8181
}"#
82-
.to_string();
82+
.to_owned();
8383
builder.insert(range.end(), code)
8484
},
8585
)

crates/ide-assists/src/handlers/generate_trait_from_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub(crate) fn generate_trait_from_impl(acc: &mut Assists, ctx: &AssistContext<'_
118118
let arg_list = if let Some(genpars) = impl_ast.generic_param_list() {
119119
genpars.to_generic_args().to_string()
120120
} else {
121-
"".to_string()
121+
"".to_owned()
122122
};
123123

124124
if let Some(snippet_cap) = ctx.config.snippet_cap {

crates/ide-assists/src/handlers/inline_const_as_literal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub(crate) fn inline_const_as_literal(acc: &mut Assists, ctx: &AssistContext<'_>
6060

6161
let id = AssistId("inline_const_as_literal", AssistKind::RefactorInline);
6262

63-
let label = "Inline const as literal".to_string();
63+
let label = "Inline const as literal".to_owned();
6464
let target = variable.syntax().text_range();
6565

6666
return acc.add(id, label, target, |edit| {

0 commit comments

Comments
 (0)