diff --git a/crates/oxc/examples/compiler.rs b/crates/oxc/examples/compiler.rs index b0fe763612562..85befbd8c72e0 100644 --- a/crates/oxc/examples/compiler.rs +++ b/crates/oxc/examples/compiler.rs @@ -35,7 +35,7 @@ fn main() -> io::Result<()> { } Err(errors) => { for error in errors { - let error = error.with_source_code(source_text.to_string()); + let error = error.with_source_code(source_text.clone()); println!("{error:?}"); } } diff --git a/crates/oxc_diagnostics/src/service.rs b/crates/oxc_diagnostics/src/service.rs index b6682e875a5dd..7e21c955e2cd6 100644 --- a/crates/oxc_diagnostics/src/service.rs +++ b/crates/oxc_diagnostics/src/service.rs @@ -369,7 +369,7 @@ mod tests { for (path, expected) in paths.iter().zip(expected) { let uri = from_file_path(path).unwrap(); - assert_eq!(uri.to_string(), expected); + assert_eq!(uri.clone(), expected); } } diff --git a/crates/oxc_estree/src/serialize/strings.rs b/crates/oxc_estree/src/serialize/strings.rs index da2cbcbd970fd..0f8a0a823cdc7 100644 --- a/crates/oxc_estree/src/serialize/strings.rs +++ b/crates/oxc_estree/src/serialize/strings.rs @@ -478,7 +478,7 @@ mod tests { for (input, output) in cases { let mut serializer = CompactTSSerializer::default(); - input.to_string().serialize(&mut serializer); + input.clone().serialize(&mut serializer); let s = serializer.into_string(); assert_eq!(&s, output); } diff --git a/crates/oxc_language_server/src/backend.rs b/crates/oxc_language_server/src/backend.rs index f4be0ab0883ee..1a3b7681dafd9 100644 --- a/crates/oxc_language_server/src/backend.rs +++ b/crates/oxc_language_server/src/backend.rs @@ -513,7 +513,7 @@ impl LanguageServer for Backend { if self.capabilities.get().is_some_and(|option| option.dynamic_formatting) && let Some(content) = &content { - self.file_system.write().await.set(uri, content.to_string()); + self.file_system.write().await.set(uri, content.clone()); } if let Some(diagnostics) = worker.lint_file(uri, content, ServerLinterRun::OnType).await { @@ -541,7 +541,7 @@ impl LanguageServer for Backend { let content = params.text_document.text; if self.capabilities.get().is_some_and(|option| option.dynamic_formatting) { - self.file_system.write().await.set(uri, content.to_string()); + self.file_system.write().await.set(uri, content.clone()); } if let Some(diagnostics) = diff --git a/crates/oxc_language_server/src/formatter/server_formatter.rs b/crates/oxc_language_server/src/formatter/server_formatter.rs index 0f261a8fa4958..530170fead4f5 100644 --- a/crates/oxc_language_server/src/formatter/server_formatter.rs +++ b/crates/oxc_language_server/src/formatter/server_formatter.rs @@ -119,7 +119,7 @@ impl ServerFormatter { #[expect(clippy::unused_self)] pub fn get_watcher_patterns(&self, options: &LSPFormatOptions) -> Vec { if let Some(config_path) = options.config_path.as_ref() { - return vec![config_path.to_string()]; + return vec![config_path.clone()]; } FORMAT_CONFIG_FILES.iter().map(|file| (*file).to_string()).collect() diff --git a/crates/oxc_language_server/src/tester.rs b/crates/oxc_language_server/src/tester.rs index 459207c65f3bd..891cb85e49eea 100644 --- a/crates/oxc_language_server/src/tester.rs +++ b/crates/oxc_language_server/src/tester.rs @@ -30,7 +30,7 @@ pub fn get_file_uri(relative_file_path: &str) -> Uri { fn get_snapshot_from_report(report: &DiagnosticReport) -> String { let code = match &report.diagnostic.code { Some(NumberOrString::Number(code)) => code.to_string(), - Some(NumberOrString::String(code)) => code.to_string(), + Some(NumberOrString::String(code)) => code.clone(), None => "None".to_string(), }; let code_description_href = match &report.diagnostic.code_description { diff --git a/crates/oxc_linter/src/rules/eslint/no_restricted_globals.rs b/crates/oxc_linter/src/rules/eslint/no_restricted_globals.rs index 36944c0b400d3..be34ffa4fc521 100644 --- a/crates/oxc_linter/src/rules/eslint/no_restricted_globals.rs +++ b/crates/oxc_linter/src/rules/eslint/no_restricted_globals.rs @@ -62,7 +62,7 @@ impl Rule for NoRestrictedGlobals { Value::Array(arr) => arr.iter().fold(FxHashMap::default(), |mut acc, v| match v { // "no-restricted-globals": ["error", "event"] Value::String(name) => { - acc.insert(name.to_string(), String::new()); + acc.insert(name.clone(), String::new()); acc } // "no-restricted-globals": ["error", { "name": "event", "message": "Use local parameter instead." }] diff --git a/crates/oxc_linter/src/rules/eslint/sort_keys.rs b/crates/oxc_linter/src/rules/eslint/sort_keys.rs index 9a1f54cbb43f4..95864d884fc2c 100644 --- a/crates/oxc_linter/src/rules/eslint/sort_keys.rs +++ b/crates/oxc_linter/src/rules/eslint/sort_keys.rs @@ -260,7 +260,7 @@ impl Rule for SortKeys { .iter() .map(|(k, _)| { if self.case_sensitive { - k.to_string() + k.clone() } else { k.cow_to_ascii_lowercase().to_string() } diff --git a/crates/oxc_linter/src/rules/typescript/no_inferrable_types.rs b/crates/oxc_linter/src/rules/typescript/no_inferrable_types.rs index 3e635202dd713..7f35b64004438 100644 --- a/crates/oxc_linter/src/rules/typescript/no_inferrable_types.rs +++ b/crates/oxc_linter/src/rules/typescript/no_inferrable_types.rs @@ -464,7 +464,7 @@ fn test() { ), ]; - let _fix = vec![ + let _fix = [ ( "const fn = (a?: number = 5) => {};", "const fn = (a = 5) => {};", diff --git a/crates/oxc_linter/src/rules/unicorn/prefer_math_min_max.rs b/crates/oxc_linter/src/rules/unicorn/prefer_math_min_max.rs index 1e16c3818ecbc..8ce9d377ac713 100644 --- a/crates/oxc_linter/src/rules/unicorn/prefer_math_min_max.rs +++ b/crates/oxc_linter/src/rules/unicorn/prefer_math_min_max.rs @@ -106,12 +106,12 @@ fn get_expr_value(expr: &Expression) -> Option { let mut unary_str: String = String::from(lit.operator.as_str()); let Some(unary_lit) = get_expr_value(&lit.argument) else { - return Some(unary_str.to_string()); + return Some(unary_str.clone()); }; unary_str.push_str(unary_lit.as_str()); - Some(unary_str.to_string()) + Some(unary_str.clone()) } Expression::Identifier(identifier) => Some(identifier.name.to_string()), _ => None, diff --git a/crates/oxc_span/src/compact_str.rs b/crates/oxc_span/src/compact_str.rs index 3bd44e4941f9c..2457270c1a6af 100644 --- a/crates/oxc_span/src/compact_str.rs +++ b/crates/oxc_span/src/compact_str.rs @@ -13,7 +13,7 @@ use crate::Span; /// Maximum length for inline string, which can be created with [`CompactStr::new_const`]. pub const MAX_INLINE_LEN: usize = 16; -/// Lifetimeless version of [`Atom<'_>`] which owns its own string data allocation. +/// Lifetimeless version of [`crate::Atom`] which owns its own string data allocation. /// /// [`CompactStr`] is immutable. Use [`CompactStr::into_string`] for a mutable /// [`String`]. diff --git a/crates/oxc_transformer/tests/integrations/es_target.rs b/crates/oxc_transformer/tests/integrations/es_target.rs index 966d47b02d1c8..b68fcb02edd76 100644 --- a/crates/oxc_transformer/tests/integrations/es_target.rs +++ b/crates/oxc_transformer/tests/integrations/es_target.rs @@ -78,6 +78,6 @@ fn target_list_fail() { for (target, expected) in targets { let result = TransformOptions::from_target(target); - assert_eq!(result.unwrap_err().to_string(), expected); + assert_eq!(result.unwrap_err().clone(), expected); } } diff --git a/napi/playground/src/lib.rs b/napi/playground/src/lib.rs index e9b5740531452..1c308819f3cd6 100644 --- a/napi/playground/src/lib.rs +++ b/napi/playground/src/lib.rs @@ -386,7 +386,7 @@ impl Oxc { let semantic = semantic_ret.semantic; let lint_config = if linter_options.config.is_some() { let oxlintrc = - Oxlintrc::from_string(&linter_options.config.as_ref().unwrap().to_string()) + Oxlintrc::from_string(&linter_options.config.as_ref().unwrap().clone()) .unwrap_or_default(); let config_builder = ConfigStoreBuilder::from_oxlintrc( false, diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 2ce412d5ad4ce..1612370a6921f 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.90.0" +channel = "1.91.0" profile = "default" diff --git a/tasks/ast_tools/src/parse/parse.rs b/tasks/ast_tools/src/parse/parse.rs index d3c4bbf2d8f68..0e5034f88b13f 100644 --- a/tasks/ast_tools/src/parse/parse.rs +++ b/tasks/ast_tools/src/parse/parse.rs @@ -822,7 +822,7 @@ impl<'c> Parser<'c> { Skeleton::Enum(skeleton) => (skeleton.name, skeleton.file_id, skeleton.item.attrs), }; - let mut meta_type = MetaType::new(meta_id, type_name.to_string(), file_id); + let mut meta_type = MetaType::new(meta_id, type_name.clone(), file_id); // Process attributes for attr in &attrs { diff --git a/tasks/coverage/src/tools/formatter.rs b/tasks/coverage/src/tools/formatter.rs index d5e0c6a6280a9..7b92450b494c4 100644 --- a/tasks/coverage/src/tools/formatter.rs +++ b/tasks/coverage/src/tools/formatter.rs @@ -148,7 +148,7 @@ impl Case for FormatterTypeScriptCase { fn run(&mut self) { let units = self.base.units.clone(); for unit in units { - self.base.code = unit.content.to_string(); + self.base.code.clone_from(&unit.content); let result = get_result(&unit.content, unit.source_type); if result != TestResult::Passed { self.base.result = result; diff --git a/tasks/coverage/src/tools/semantic.rs b/tasks/coverage/src/tools/semantic.rs index 2a4b9ac743448..c4b26d9a97685 100644 --- a/tasks/coverage/src/tools/semantic.rs +++ b/tasks/coverage/src/tools/semantic.rs @@ -156,7 +156,7 @@ impl Case for SemanticTypeScriptCase { fn run(&mut self) { let units = self.base.units.clone(); for unit in units { - self.base.code = unit.content.to_string(); + self.base.code.clone_from(&unit.content); let result = self.execute(unit.source_type); if result != TestResult::Passed { self.base.result = result; diff --git a/tasks/coverage/src/tools/transformer.rs b/tasks/coverage/src/tools/transformer.rs index ee188bf97408c..90090b228c11c 100644 --- a/tasks/coverage/src/tools/transformer.rs +++ b/tasks/coverage/src/tools/transformer.rs @@ -161,7 +161,7 @@ impl Case for TransformerTypeScriptCase { fn run(&mut self) { let units = self.base.units.clone(); for unit in units { - self.base.code = unit.content.to_string(); + self.base.code.clone_from(&unit.content); let result = self.execute(unit.source_type); if result != TestResult::Passed { self.base.result = result; diff --git a/tasks/rulegen/src/main.rs b/tasks/rulegen/src/main.rs index 3e49dde52ad01..42aad82186526 100644 --- a/tasks/rulegen/src/main.rs +++ b/tasks/rulegen/src/main.rs @@ -465,7 +465,7 @@ impl<'a> State<'a> { .map(|arg| { let case = TestCase::new(self.source_text, arg); if let Some(group_comment) = self.expression_to_group_comment_map.get(&arg.span()) { - case.with_group_comment(group_comment.to_string()) + case.with_group_comment(group_comment.clone()) } else { case }