Skip to content

Commit d00f1c1

Browse files
ide-diagnostics: Fix warnings about clippy str_to_string rule
1 parent eba1b13 commit d00f1c1

22 files changed

+36
-36
lines changed

crates/ide-diagnostics/src/handlers/inactive_code.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub(crate) fn inactive_code(
1616
}
1717

1818
let inactive = DnfExpr::new(d.cfg.clone()).why_inactive(&d.opts);
19-
let mut message = "code is inactive due to #[cfg] directives".to_string();
19+
let mut message = "code is inactive due to #[cfg] directives".to_owned();
2020

2121
if let Some(inactive) = inactive {
2222
let inactive_reasons = inactive.to_string();

crates/ide-diagnostics/src/handlers/incoherent_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub(crate) fn incoherent_impl(ctx: &DiagnosticsContext<'_>, d: &hir::IncoherentI
99
Diagnostic::new_with_syntax_node_ptr(
1010
ctx,
1111
DiagnosticCode::RustcHardError("E0210"),
12-
"cannot define inherent `impl` for foreign type".to_string(),
12+
"cannot define inherent `impl` for foreign type".to_owned(),
1313
InFile::new(d.file_id, d.impl_.into()),
1414
)
1515
}

crates/ide-diagnostics/src/handlers/incorrect_case.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ impl BAD_TRAIT for () {
512512
fn BadFunction() {}
513513
}
514514
"#,
515-
std::iter::once("unused_variables".to_string()),
515+
std::iter::once("unused_variables".to_owned()),
516516
);
517517
}
518518

crates/ide-diagnostics/src/handlers/json_is_not_rust.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ impl State {
4242
v.push("Deserialize");
4343
}
4444
match v.as_slice() {
45-
[] => "".to_string(),
45+
[] => "".to_owned(),
4646
[x] => format!("#[derive({x})]\n"),
4747
[x, y] => format!("#[derive({x}, {y})]\n"),
4848
_ => {
4949
never!();
50-
"".to_string()
50+
"".to_owned()
5151
}
5252
}
5353
}
@@ -176,7 +176,7 @@ mod tests {
176176
#[test]
177177
fn diagnostic_for_simple_case() {
178178
let mut config = DiagnosticsConfig::test_sample();
179-
config.disabled.insert("syntax-error".to_string());
179+
config.disabled.insert("syntax-error".to_owned());
180180
check_diagnostics_with_config(
181181
config,
182182
r#"

crates/ide-diagnostics/src/handlers/macro_error.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub macro panic {
9999

100100
// FIXME: This is a false-positive, the file is actually linked in via
101101
// `include!` macro
102-
config.disabled.insert("unlinked-file".to_string());
102+
config.disabled.insert("unlinked-file".to_owned());
103103

104104
check_diagnostics_with_config(
105105
config,
@@ -268,8 +268,8 @@ fn f() {
268268
#[test]
269269
fn include_does_not_break_diagnostics() {
270270
let mut config = DiagnosticsConfig::test_sample();
271-
config.disabled.insert("inactive-code".to_string());
272-
config.disabled.insert("unlinked-file".to_string());
271+
config.disabled.insert("inactive-code".to_owned());
272+
config.disabled.insert("unlinked-file".to_owned());
273273
check_diagnostics_with_config(
274274
config,
275275
r#"

crates/ide-diagnostics/src/handlers/missing_fields.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ fn make_ty(ty: &hir::Type, db: &dyn HirDatabase, module: hir::Module) -> ast::Ty
170170
let ty_str = match ty.as_adt() {
171171
Some(adt) => adt.name(db).display(db.upcast()).to_string(),
172172
None => {
173-
ty.display_source_code(db, module.into(), false).ok().unwrap_or_else(|| "_".to_string())
173+
ty.display_source_code(db, module.into(), false).ok().unwrap_or_else(|| "_".to_owned())
174174
}
175175
};
176176

crates/ide-diagnostics/src/handlers/missing_match_arms.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ mod tests {
3131
#[test]
3232
fn empty_body() {
3333
let mut config = DiagnosticsConfig::test_sample();
34-
config.disabled.insert("syntax-error".to_string());
34+
config.disabled.insert("syntax-error".to_owned());
3535
check_diagnostics_with_config(
3636
config,
3737
r#"

crates/ide-diagnostics/src/handlers/mutability_errors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub(crate) fn need_mut(ctx: &DiagnosticsContext<'_>, d: &hir::NeedMut) -> Diagno
1919
for source in d.local.sources(ctx.sema.db) {
2020
let Some(ast) = source.name() else { continue };
2121
// FIXME: macros
22-
edit_builder.insert(ast.value.syntax().text_range().start(), "mut ".to_string());
22+
edit_builder.insert(ast.value.syntax().text_range().start(), "mut ".to_owned());
2323
}
2424
let edit = edit_builder.finish();
2525
Some(vec![fix(
@@ -448,7 +448,7 @@ fn main(b: bool) {
448448
&mut x;
449449
}
450450
"#,
451-
std::iter::once("remove-unnecessary-else".to_string()),
451+
std::iter::once("remove-unnecessary-else".to_owned()),
452452
);
453453
check_diagnostics_with_disabled(
454454
r#"
@@ -463,7 +463,7 @@ fn main(b: bool) {
463463
&mut x;
464464
}
465465
"#,
466-
std::iter::once("remove-unnecessary-else".to_string()),
466+
std::iter::once("remove-unnecessary-else".to_owned()),
467467
);
468468
}
469469

crates/ide-diagnostics/src/handlers/remove_trailing_return.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ fn foo(x: usize) -> u8 {
140140
} //^^^^^^^^^ 💡 weak: replace return <expr>; with <expr>
141141
}
142142
"#,
143-
std::iter::once("remove-unnecessary-else".to_string()),
143+
std::iter::once("remove-unnecessary-else".to_owned()),
144144
);
145145
}
146146

@@ -309,7 +309,7 @@ fn foo(x: usize) -> u8 {
309309
}
310310
}
311311
"#,
312-
std::iter::once("remove-unnecessary-else".to_string()),
312+
std::iter::once("remove-unnecessary-else".to_owned()),
313313
);
314314
check_fix(
315315
r#"

crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ mod tests {
9090
use crate::tests::{check_diagnostics, check_diagnostics_with_disabled, check_fix};
9191

9292
fn check_diagnostics_with_needless_return_disabled(ra_fixture: &str) {
93-
check_diagnostics_with_disabled(ra_fixture, std::iter::once("needless_return".to_string()));
93+
check_diagnostics_with_disabled(ra_fixture, std::iter::once("needless_return".to_owned()));
9494
}
9595

9696
#[test]

0 commit comments

Comments
 (0)