Unnamed repository; edit this file 'description' to name the repository.
ide-diagnostics: Fix warnings about clippy `str_to_string` rule
Tetsuharu Ohzeki 2024-02-09
parent eba1b13 · commit d00f1c1
-rw-r--r--crates/ide-diagnostics/src/handlers/inactive_code.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/incoherent_impl.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/incorrect_case.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/json_is_not_rust.rs6
-rw-r--r--crates/ide-diagnostics/src/handlers/macro_error.rs6
-rw-r--r--crates/ide-diagnostics/src/handlers/missing_fields.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/missing_match_arms.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/mutability_errors.rs6
-rw-r--r--crates/ide-diagnostics/src/handlers/remove_trailing_return.rs4
-rw-r--r--crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/replace_filter_map_next_with_find_map.rs4
-rw-r--r--crates/ide-diagnostics/src/handlers/trait_impl_orphan.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/trait_impl_redundant_assoc_item.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/type_mismatch.rs6
-rw-r--r--crates/ide-diagnostics/src/handlers/unimplemented_builtin_macro.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/unresolved_field.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/unresolved_method.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/unresolved_module.rs4
-rw-r--r--crates/ide-diagnostics/src/handlers/unresolved_proc_macro.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/useless_braces.rs4
-rw-r--r--crates/ide-diagnostics/src/lib.rs2
-rw-r--r--crates/ide-diagnostics/src/tests.rs6
22 files changed, 36 insertions, 36 deletions
diff --git a/crates/ide-diagnostics/src/handlers/inactive_code.rs b/crates/ide-diagnostics/src/handlers/inactive_code.rs
index 9f754f9c6f..7db5ea04fb 100644
--- a/crates/ide-diagnostics/src/handlers/inactive_code.rs
+++ b/crates/ide-diagnostics/src/handlers/inactive_code.rs
@@ -16,7 +16,7 @@ pub(crate) fn inactive_code(
}
let inactive = DnfExpr::new(d.cfg.clone()).why_inactive(&d.opts);
- let mut message = "code is inactive due to #[cfg] directives".to_string();
+ let mut message = "code is inactive due to #[cfg] directives".to_owned();
if let Some(inactive) = inactive {
let inactive_reasons = inactive.to_string();
diff --git a/crates/ide-diagnostics/src/handlers/incoherent_impl.rs b/crates/ide-diagnostics/src/handlers/incoherent_impl.rs
index 3b4d400912..9f56e10414 100644
--- a/crates/ide-diagnostics/src/handlers/incoherent_impl.rs
+++ b/crates/ide-diagnostics/src/handlers/incoherent_impl.rs
@@ -9,7 +9,7 @@ pub(crate) fn incoherent_impl(ctx: &DiagnosticsContext<'_>, d: &hir::IncoherentI
Diagnostic::new_with_syntax_node_ptr(
ctx,
DiagnosticCode::RustcHardError("E0210"),
- "cannot define inherent `impl` for foreign type".to_string(),
+ "cannot define inherent `impl` for foreign type".to_owned(),
InFile::new(d.file_id, d.impl_.into()),
)
}
diff --git a/crates/ide-diagnostics/src/handlers/incorrect_case.rs b/crates/ide-diagnostics/src/handlers/incorrect_case.rs
index 96fbb4468f..dd64b93e45 100644
--- a/crates/ide-diagnostics/src/handlers/incorrect_case.rs
+++ b/crates/ide-diagnostics/src/handlers/incorrect_case.rs
@@ -512,7 +512,7 @@ impl BAD_TRAIT for () {
fn BadFunction() {}
}
"#,
- std::iter::once("unused_variables".to_string()),
+ std::iter::once("unused_variables".to_owned()),
);
}
diff --git a/crates/ide-diagnostics/src/handlers/json_is_not_rust.rs b/crates/ide-diagnostics/src/handlers/json_is_not_rust.rs
index d330973aaa..241fddbb90 100644
--- a/crates/ide-diagnostics/src/handlers/json_is_not_rust.rs
+++ b/crates/ide-diagnostics/src/handlers/json_is_not_rust.rs
@@ -42,12 +42,12 @@ impl State {
v.push("Deserialize");
}
match v.as_slice() {
- [] => "".to_string(),
+ [] => "".to_owned(),
[x] => format!("#[derive({x})]\n"),
[x, y] => format!("#[derive({x}, {y})]\n"),
_ => {
never!();
- "".to_string()
+ "".to_owned()
}
}
}
@@ -176,7 +176,7 @@ mod tests {
#[test]
fn diagnostic_for_simple_case() {
let mut config = DiagnosticsConfig::test_sample();
- config.disabled.insert("syntax-error".to_string());
+ config.disabled.insert("syntax-error".to_owned());
check_diagnostics_with_config(
config,
r#"
diff --git a/crates/ide-diagnostics/src/handlers/macro_error.rs b/crates/ide-diagnostics/src/handlers/macro_error.rs
index fc5c715981..e4cb53f3a2 100644
--- a/crates/ide-diagnostics/src/handlers/macro_error.rs
+++ b/crates/ide-diagnostics/src/handlers/macro_error.rs
@@ -99,7 +99,7 @@ pub macro panic {
// FIXME: This is a false-positive, the file is actually linked in via
// `include!` macro
- config.disabled.insert("unlinked-file".to_string());
+ config.disabled.insert("unlinked-file".to_owned());
check_diagnostics_with_config(
config,
@@ -268,8 +268,8 @@ fn f() {
#[test]
fn include_does_not_break_diagnostics() {
let mut config = DiagnosticsConfig::test_sample();
- config.disabled.insert("inactive-code".to_string());
- config.disabled.insert("unlinked-file".to_string());
+ config.disabled.insert("inactive-code".to_owned());
+ config.disabled.insert("unlinked-file".to_owned());
check_diagnostics_with_config(
config,
r#"
diff --git a/crates/ide-diagnostics/src/handlers/missing_fields.rs b/crates/ide-diagnostics/src/handlers/missing_fields.rs
index 3bc043c8fc..c70f39eb28 100644
--- a/crates/ide-diagnostics/src/handlers/missing_fields.rs
+++ b/crates/ide-diagnostics/src/handlers/missing_fields.rs
@@ -170,7 +170,7 @@ fn make_ty(ty: &hir::Type, db: &dyn HirDatabase, module: hir::Module) -> ast::Ty
let ty_str = match ty.as_adt() {
Some(adt) => adt.name(db).display(db.upcast()).to_string(),
None => {
- ty.display_source_code(db, module.into(), false).ok().unwrap_or_else(|| "_".to_string())
+ ty.display_source_code(db, module.into(), false).ok().unwrap_or_else(|| "_".to_owned())
}
};
diff --git a/crates/ide-diagnostics/src/handlers/missing_match_arms.rs b/crates/ide-diagnostics/src/handlers/missing_match_arms.rs
index cb6d568442..17dc679e05 100644
--- a/crates/ide-diagnostics/src/handlers/missing_match_arms.rs
+++ b/crates/ide-diagnostics/src/handlers/missing_match_arms.rs
@@ -31,7 +31,7 @@ mod tests {
#[test]
fn empty_body() {
let mut config = DiagnosticsConfig::test_sample();
- config.disabled.insert("syntax-error".to_string());
+ config.disabled.insert("syntax-error".to_owned());
check_diagnostics_with_config(
config,
r#"
diff --git a/crates/ide-diagnostics/src/handlers/mutability_errors.rs b/crates/ide-diagnostics/src/handlers/mutability_errors.rs
index d9804cbd94..bdb55a9d98 100644
--- a/crates/ide-diagnostics/src/handlers/mutability_errors.rs
+++ b/crates/ide-diagnostics/src/handlers/mutability_errors.rs
@@ -19,7 +19,7 @@ pub(crate) fn need_mut(ctx: &DiagnosticsContext<'_>, d: &hir::NeedMut) -> Diagno
for source in d.local.sources(ctx.sema.db) {
let Some(ast) = source.name() else { continue };
// FIXME: macros
- edit_builder.insert(ast.value.syntax().text_range().start(), "mut ".to_string());
+ edit_builder.insert(ast.value.syntax().text_range().start(), "mut ".to_owned());
}
let edit = edit_builder.finish();
Some(vec![fix(
@@ -448,7 +448,7 @@ fn main(b: bool) {
&mut x;
}
"#,
- std::iter::once("remove-unnecessary-else".to_string()),
+ std::iter::once("remove-unnecessary-else".to_owned()),
);
check_diagnostics_with_disabled(
r#"
@@ -463,7 +463,7 @@ fn main(b: bool) {
&mut x;
}
"#,
- std::iter::once("remove-unnecessary-else".to_string()),
+ std::iter::once("remove-unnecessary-else".to_owned()),
);
}
diff --git a/crates/ide-diagnostics/src/handlers/remove_trailing_return.rs b/crates/ide-diagnostics/src/handlers/remove_trailing_return.rs
index 605e8baba0..a0d5d742d3 100644
--- a/crates/ide-diagnostics/src/handlers/remove_trailing_return.rs
+++ b/crates/ide-diagnostics/src/handlers/remove_trailing_return.rs
@@ -140,7 +140,7 @@ fn foo(x: usize) -> u8 {
} //^^^^^^^^^ 💡 weak: replace return <expr>; with <expr>
}
"#,
- std::iter::once("remove-unnecessary-else".to_string()),
+ std::iter::once("remove-unnecessary-else".to_owned()),
);
}
@@ -309,7 +309,7 @@ fn foo(x: usize) -> u8 {
}
}
"#,
- std::iter::once("remove-unnecessary-else".to_string()),
+ std::iter::once("remove-unnecessary-else".to_owned()),
);
check_fix(
r#"
diff --git a/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs b/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs
index 124086c8fa..ae8241ec2c 100644
--- a/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs
+++ b/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs
@@ -90,7 +90,7 @@ mod tests {
use crate::tests::{check_diagnostics, check_diagnostics_with_disabled, check_fix};
fn check_diagnostics_with_needless_return_disabled(ra_fixture: &str) {
- check_diagnostics_with_disabled(ra_fixture, std::iter::once("needless_return".to_string()));
+ check_diagnostics_with_disabled(ra_fixture, std::iter::once("needless_return".to_owned()));
}
#[test]
diff --git a/crates/ide-diagnostics/src/handlers/replace_filter_map_next_with_find_map.rs b/crates/ide-diagnostics/src/handlers/replace_filter_map_next_with_find_map.rs
index 72896b891b..6d3dcf31ab 100644
--- a/crates/ide-diagnostics/src/handlers/replace_filter_map_next_with_find_map.rs
+++ b/crates/ide-diagnostics/src/handlers/replace_filter_map_next_with_find_map.rs
@@ -63,8 +63,8 @@ mod tests {
#[track_caller]
pub(crate) fn check_diagnostics(ra_fixture: &str) {
let mut config = DiagnosticsConfig::test_sample();
- config.disabled.insert("inactive-code".to_string());
- config.disabled.insert("E0599".to_string());
+ config.disabled.insert("inactive-code".to_owned());
+ config.disabled.insert("E0599".to_owned());
check_diagnostics_with_config(config, ra_fixture)
}
diff --git a/crates/ide-diagnostics/src/handlers/trait_impl_orphan.rs b/crates/ide-diagnostics/src/handlers/trait_impl_orphan.rs
index d36813381e..78a04e1542 100644
--- a/crates/ide-diagnostics/src/handlers/trait_impl_orphan.rs
+++ b/crates/ide-diagnostics/src/handlers/trait_impl_orphan.rs
@@ -13,7 +13,7 @@ pub(crate) fn trait_impl_orphan(
ctx,
DiagnosticCode::RustcHardError("E0117"),
"only traits defined in the current crate can be implemented for arbitrary types"
- .to_string(),
+ .to_owned(),
InFile::new(d.file_id, d.impl_.into()),
)
// Not yet checked for false positives
diff --git a/crates/ide-diagnostics/src/handlers/trait_impl_redundant_assoc_item.rs b/crates/ide-diagnostics/src/handlers/trait_impl_redundant_assoc_item.rs
index f58fcd1f7e..00710ef507 100644
--- a/crates/ide-diagnostics/src/handlers/trait_impl_redundant_assoc_item.rs
+++ b/crates/ide-diagnostics/src/handlers/trait_impl_redundant_assoc_item.rs
@@ -103,7 +103,7 @@ fn quickfix_for_redundant_assoc_item(
Some(vec![Assist {
id: AssistId("add assoc item def into trait def", AssistKind::QuickFix),
- label: Label::new("Add assoc item def into trait def".to_string()),
+ label: Label::new("Add assoc item def into trait def".to_owned()),
group: None,
target: range,
source_change: Some(source_change_builder.finish()),
diff --git a/crates/ide-diagnostics/src/handlers/type_mismatch.rs b/crates/ide-diagnostics/src/handlers/type_mismatch.rs
index eec8efe785..e93eea8ce2 100644
--- a/crates/ide-diagnostics/src/handlers/type_mismatch.rs
+++ b/crates/ide-diagnostics/src/handlers/type_mismatch.rs
@@ -120,7 +120,7 @@ fn add_missing_ok_or_some(
let mut builder = TextEdit::builder();
builder.insert(expr.syntax().text_range().start(), format!("{variant_name}("));
- builder.insert(expr.syntax().text_range().end(), ")".to_string());
+ builder.insert(expr.syntax().text_range().end(), ")".to_owned());
let source_change =
SourceChange::from_text_edit(expr_ptr.file_id.original_file(ctx.sema.db), builder.finish());
let name = format!("Wrap in {variant_name}");
@@ -174,7 +174,7 @@ fn str_ref_to_owned(
let expr = expr_ptr.value.to_node(&root);
let expr_range = expr.syntax().text_range();
- let to_owned = ".to_owned()".to_string();
+ let to_owned = ".to_owned()".to_owned();
let edit = TextEdit::insert(expr.syntax().text_range().end(), to_owned);
let source_change =
@@ -729,7 +729,7 @@ fn f() -> i32 {
}
fn g() { return; }
"#,
- std::iter::once("needless_return".to_string()),
+ std::iter::once("needless_return".to_owned()),
);
}
diff --git a/crates/ide-diagnostics/src/handlers/unimplemented_builtin_macro.rs b/crates/ide-diagnostics/src/handlers/unimplemented_builtin_macro.rs
index 996b6eda59..06f176f86f 100644
--- a/crates/ide-diagnostics/src/handlers/unimplemented_builtin_macro.rs
+++ b/crates/ide-diagnostics/src/handlers/unimplemented_builtin_macro.rs
@@ -10,7 +10,7 @@ pub(crate) fn unimplemented_builtin_macro(
Diagnostic::new_with_syntax_node_ptr(
ctx,
DiagnosticCode::Ra("unimplemented-builtin-macro", Severity::WeakWarning),
- "unimplemented built-in macro".to_string(),
+ "unimplemented built-in macro".to_owned(),
d.node,
)
}
diff --git a/crates/ide-diagnostics/src/handlers/unresolved_field.rs b/crates/ide-diagnostics/src/handlers/unresolved_field.rs
index 0e7a5720d4..65abfd8a29 100644
--- a/crates/ide-diagnostics/src/handlers/unresolved_field.rs
+++ b/crates/ide-diagnostics/src/handlers/unresolved_field.rs
@@ -65,7 +65,7 @@ fn method_fix(
let FileRange { range, file_id } = ctx.sema.original_range_opt(expr.syntax())?;
Some(vec![Assist {
id: AssistId("expected-field-found-method-call-fix", AssistKind::QuickFix),
- label: Label::new("Use parentheses to call the method".to_string()),
+ label: Label::new("Use parentheses to call the method".to_owned()),
group: None,
target: range,
source_change: Some(SourceChange::from_text_edit(
diff --git a/crates/ide-diagnostics/src/handlers/unresolved_method.rs b/crates/ide-diagnostics/src/handlers/unresolved_method.rs
index 9f8fee67f3..648d081898 100644
--- a/crates/ide-diagnostics/src/handlers/unresolved_method.rs
+++ b/crates/ide-diagnostics/src/handlers/unresolved_method.rs
@@ -101,7 +101,7 @@ fn field_fix(
};
Some(Assist {
id: AssistId("expected-method-found-field-fix", AssistKind::QuickFix),
- label: Label::new("Use parentheses to call the value of the field".to_string()),
+ label: Label::new("Use parentheses to call the value of the field".to_owned()),
group: None,
target: range,
source_change: Some(SourceChange::from_iter([
diff --git a/crates/ide-diagnostics/src/handlers/unresolved_module.rs b/crates/ide-diagnostics/src/handlers/unresolved_module.rs
index 1604decf90..1155688324 100644
--- a/crates/ide-diagnostics/src/handlers/unresolved_module.rs
+++ b/crates/ide-diagnostics/src/handlers/unresolved_module.rs
@@ -16,7 +16,7 @@ pub(crate) fn unresolved_module(
ctx,
DiagnosticCode::RustcHardError("E0583"),
match &*d.candidates {
- [] => "unresolved module".to_string(),
+ [] => "unresolved module".to_owned(),
[candidate] => format!("unresolved module, can't find module file: {candidate}"),
[candidates @ .., last] => {
format!(
@@ -46,7 +46,7 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::UnresolvedModule) -> Option<Vec<
anchor: d.decl.file_id.original_file(ctx.sema.db),
path: candidate.clone(),
},
- initial_contents: "".to_string(),
+ initial_contents: "".to_owned(),
}
.into(),
unresolved_module.syntax().text_range(),
diff --git a/crates/ide-diagnostics/src/handlers/unresolved_proc_macro.rs b/crates/ide-diagnostics/src/handlers/unresolved_proc_macro.rs
index 340f77feea..7ea50c496f 100644
--- a/crates/ide-diagnostics/src/handlers/unresolved_proc_macro.rs
+++ b/crates/ide-diagnostics/src/handlers/unresolved_proc_macro.rs
@@ -27,7 +27,7 @@ pub(crate) fn unresolved_proc_macro(
let not_expanded_message = match &d.macro_name {
Some(name) => format!("proc macro `{name}` not expanded"),
- None => "proc macro not expanded".to_string(),
+ None => "proc macro not expanded".to_owned(),
};
let severity = if config_enabled { Severity::Error } else { Severity::WeakWarning };
let def_map = ctx.sema.db.crate_def_map(d.krate);
diff --git a/crates/ide-diagnostics/src/handlers/useless_braces.rs b/crates/ide-diagnostics/src/handlers/useless_braces.rs
index 8dce2af23e..863a7ab783 100644
--- a/crates/ide-diagnostics/src/handlers/useless_braces.rs
+++ b/crates/ide-diagnostics/src/handlers/useless_braces.rs
@@ -40,7 +40,7 @@ pub(crate) fn useless_braces(
acc.push(
Diagnostic::new(
DiagnosticCode::RustcLint("unused_braces"),
- "Unnecessary braces in use statement".to_string(),
+ "Unnecessary braces in use statement".to_owned(),
FileRange { file_id, range: use_range },
)
.with_main_node(InFile::new(file_id.into(), node.clone()))
@@ -112,7 +112,7 @@ mod a {
);
let mut config = DiagnosticsConfig::test_sample();
- config.disabled.insert("syntax-error".to_string());
+ config.disabled.insert("syntax-error".to_owned());
check_diagnostics_with_config(
config,
r#"
diff --git a/crates/ide-diagnostics/src/lib.rs b/crates/ide-diagnostics/src/lib.rs
index 7c5cf67330..9d21bb4cd9 100644
--- a/crates/ide-diagnostics/src/lib.rs
+++ b/crates/ide-diagnostics/src/lib.rs
@@ -563,7 +563,7 @@ fn unresolved_fix(id: &'static str, label: &str, target: TextRange) -> Assist {
assert!(!id.contains(' '));
Assist {
id: AssistId(id, AssistKind::QuickFix),
- label: Label::new(label.to_string()),
+ label: Label::new(label.to_owned()),
group: None,
target,
source_change: None,
diff --git a/crates/ide-diagnostics/src/tests.rs b/crates/ide-diagnostics/src/tests.rs
index da563b874b..b62bb5affd 100644
--- a/crates/ide-diagnostics/src/tests.rs
+++ b/crates/ide-diagnostics/src/tests.rs
@@ -108,7 +108,7 @@ pub(crate) fn check_no_fix(ra_fixture: &str) {
#[track_caller]
pub(crate) fn check_diagnostics(ra_fixture: &str) {
let mut config = DiagnosticsConfig::test_sample();
- config.disabled.insert("inactive-code".to_string());
+ config.disabled.insert("inactive-code".to_owned());
check_diagnostics_with_config(config, ra_fixture)
}
@@ -207,8 +207,8 @@ fn minicore_smoke_test() {
let source = minicore.source_code();
let mut config = DiagnosticsConfig::test_sample();
// This should be ignored since we conditionally remove code which creates single item use with braces
- config.disabled.insert("unused_braces".to_string());
- config.disabled.insert("unused_variables".to_string());
+ config.disabled.insert("unused_braces".to_owned());
+ config.disabled.insert("unused_variables".to_owned());
check_diagnostics_with_config(config, &source);
}