diff --git a/crates/ruff/src/commands/format.rs b/crates/ruff/src/commands/format.rs index 1f79e59339..0e245efa8c 100644 --- a/crates/ruff/src/commands/format.rs +++ b/crates/ruff/src/commands/format.rs @@ -370,7 +370,7 @@ pub(crate) fn format_source( let line_index = LineIndex::from_source_text(unformatted); let byte_range = range.to_text_range(unformatted, &line_index); format_range(unformatted, byte_range, options).map(|formatted_range| { - let mut formatted = unformatted.to_string(); + let mut formatted = unformatted.clone(); formatted.replace_range( std::ops::Range::::from(formatted_range.source_range()), formatted_range.as_code(), diff --git a/crates/ruff_dev/src/generate_options.rs b/crates/ruff_dev/src/generate_options.rs index 8b8579d730..49a898d6fe 100644 --- a/crates/ruff_dev/src/generate_options.rs +++ b/crates/ruff_dev/src/generate_options.rs @@ -62,7 +62,7 @@ fn generate_set(output: &mut String, set: Set, parents: &mut Vec) { generate_set( output, Set::Named { - name: set_name.to_string(), + name: set_name.clone(), set: *sub_set, }, parents, diff --git a/crates/ruff_dev/src/generate_ty_options.rs b/crates/ruff_dev/src/generate_ty_options.rs index af7794a0b2..4e4ab0a949 100644 --- a/crates/ruff_dev/src/generate_ty_options.rs +++ b/crates/ruff_dev/src/generate_ty_options.rs @@ -104,7 +104,7 @@ fn generate_set(output: &mut String, set: Set, parents: &mut Vec) { generate_set( output, Set::Named { - name: set_name.to_string(), + name: set_name.clone(), set: *sub_set, }, parents, diff --git a/crates/ruff_formatter/src/builders.rs b/crates/ruff_formatter/src/builders.rs index 14da643355..ab60103d99 100644 --- a/crates/ruff_formatter/src/builders.rs +++ b/crates/ruff_formatter/src/builders.rs @@ -1006,7 +1006,7 @@ impl std::fmt::Debug for Align<'_, Context> { /// Block indents indent a block of code, such as in a function body, and therefore insert a line /// break before and after the content. /// -/// Doesn't create an indentation if the passed in content is [`FormatElement.is_empty`]. +/// Doesn't create an indentation if the passed in content is empty. /// /// # Examples /// diff --git a/crates/ruff_linter/src/rules/flake8_import_conventions/rules/unconventional_import_alias.rs b/crates/ruff_linter/src/rules/flake8_import_conventions/rules/unconventional_import_alias.rs index e0684056dc..6827e99b93 100644 --- a/crates/ruff_linter/src/rules/flake8_import_conventions/rules/unconventional_import_alias.rs +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/rules/unconventional_import_alias.rs @@ -78,7 +78,7 @@ pub(crate) fn unconventional_import_alias( let mut diagnostic = checker.report_diagnostic( UnconventionalImportAlias { name: qualified_name, - asname: expected_alias.to_string(), + asname: expected_alias.clone(), }, binding.range(), ); diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/types.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/types.rs index 0de6758635..bd57ad080c 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/types.rs +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/types.rs @@ -6,21 +6,17 @@ use ruff_macros::CacheKey; #[derive(Clone, Copy, Debug, CacheKey, PartialEq, Eq, Serialize, Deserialize)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +#[derive(Default)] pub enum ParametrizeNameType { #[serde(rename = "csv")] Csv, #[serde(rename = "tuple")] + #[default] Tuple, #[serde(rename = "list")] List, } -impl Default for ParametrizeNameType { - fn default() -> Self { - Self::Tuple - } -} - impl Display for ParametrizeNameType { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { match self { @@ -33,19 +29,15 @@ impl Display for ParametrizeNameType { #[derive(Clone, Copy, Debug, CacheKey, PartialEq, Eq, Serialize, Deserialize)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +#[derive(Default)] pub enum ParametrizeValuesType { #[serde(rename = "tuple")] Tuple, #[serde(rename = "list")] + #[default] List, } -impl Default for ParametrizeValuesType { - fn default() -> Self { - Self::List - } -} - impl Display for ParametrizeValuesType { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { match self { @@ -57,19 +49,15 @@ impl Display for ParametrizeValuesType { #[derive(Clone, Copy, Debug, CacheKey, PartialEq, Eq, Serialize, Deserialize)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +#[derive(Default)] pub enum ParametrizeValuesRowType { #[serde(rename = "tuple")] + #[default] Tuple, #[serde(rename = "list")] List, } -impl Default for ParametrizeValuesRowType { - fn default() -> Self { - Self::Tuple - } -} - impl Display for ParametrizeValuesRowType { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { match self { diff --git a/crates/ruff_linter/src/rules/flake8_quotes/settings.rs b/crates/ruff_linter/src/rules/flake8_quotes/settings.rs index b241e70b49..fe5129d6e3 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/settings.rs +++ b/crates/ruff_linter/src/rules/flake8_quotes/settings.rs @@ -9,19 +9,15 @@ use ruff_macros::CacheKey; #[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, CacheKey)] #[serde(deny_unknown_fields, rename_all = "kebab-case")] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +#[derive(Default)] pub enum Quote { /// Use double quotes. + #[default] Double, /// Use single quotes. Single, } -impl Default for Quote { - fn default() -> Self { - Self::Double - } -} - impl From for Quote { fn from(value: ruff_python_ast::str::Quote) -> Self { match value { diff --git a/crates/ruff_linter/src/rules/flake8_simplify/rules/reimplemented_builtin.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/reimplemented_builtin.rs index 9c216311ed..4c858fb799 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/rules/reimplemented_builtin.rs +++ b/crates/ruff_linter/src/rules/flake8_simplify/rules/reimplemented_builtin.rs @@ -116,7 +116,7 @@ pub(crate) fn convert_for_loop_to_any_all(checker: &Checker, stmt: &Stmt) { let mut diagnostic = checker.report_diagnostic( ReimplementedBuiltin { - replacement: contents.to_string(), + replacement: contents.clone(), }, TextRange::new(stmt.start(), terminal.stmt.end()), ); @@ -212,7 +212,7 @@ pub(crate) fn convert_for_loop_to_any_all(checker: &Checker, stmt: &Stmt) { let mut diagnostic = checker.report_diagnostic( ReimplementedBuiltin { - replacement: contents.to_string(), + replacement: contents.clone(), }, TextRange::new(stmt.start(), terminal.stmt.end()), ); diff --git a/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/banned_api.rs b/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/banned_api.rs index 6ada015222..6379304d5c 100644 --- a/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/banned_api.rs +++ b/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/banned_api.rs @@ -47,7 +47,7 @@ pub(crate) fn banned_api(checker: &Checker, policy: &NameMatchPolicy, checker.report_diagnostic( BannedApi { name: banned_module, - message: reason.msg.to_string(), + message: reason.msg.clone(), }, node.range(), ); @@ -74,8 +74,8 @@ pub(crate) fn banned_attribute_access(checker: &Checker, expr: &Expr) { { checker.report_diagnostic( BannedApi { - name: banned_path.to_string(), - message: ban.msg.to_string(), + name: banned_path.clone(), + message: ban.msg.clone(), }, expr.range(), ); diff --git a/crates/ruff_linter/src/rules/isort/settings.rs b/crates/ruff_linter/src/rules/isort/settings.rs index 05a4dddf08..cab9ab35ed 100644 --- a/crates/ruff_linter/src/rules/isort/settings.rs +++ b/crates/ruff_linter/src/rules/isort/settings.rs @@ -20,21 +20,17 @@ use super::categorize::ImportSection; #[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, CacheKey)] #[serde(deny_unknown_fields, rename_all = "kebab-case")] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +#[derive(Default)] pub enum RelativeImportsOrder { /// Place "closer" imports (fewer `.` characters, most local) before /// "further" imports (more `.` characters, least local). ClosestToFurthest, /// Place "further" imports (more `.` characters, least local) imports /// before "closer" imports (fewer `.` characters, most local). + #[default] FurthestToClosest, } -impl Default for RelativeImportsOrder { - fn default() -> Self { - Self::FurthestToClosest - } -} - impl Display for RelativeImportsOrder { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { match self { diff --git a/crates/ruff_linter/src/rules/pycodestyle/rules/literal_comparisons.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/literal_comparisons.rs index 6ae6cea817..a68e492846 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/rules/literal_comparisons.rs +++ b/crates/ruff_linter/src/rules/pycodestyle/rules/literal_comparisons.rs @@ -427,7 +427,7 @@ pub(crate) fn literal_comparisons(checker: &Checker, compare: &ast::ExprCompare) for diagnostic in &mut diagnostics { diagnostic.set_fix(Fix::unsafe_edit(Edit::range_replacement( - content.to_string(), + content.clone(), compare.range(), ))); } diff --git a/crates/ruff_linter/src/rules/pydocstyle/rules/capitalized.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/capitalized.rs index 32cfa89406..23faabc2ec 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/rules/capitalized.rs +++ b/crates/ruff_linter/src/rules/pydocstyle/rules/capitalized.rs @@ -94,7 +94,7 @@ pub(crate) fn capitalized(checker: &Checker, docstring: &Docstring) { let mut diagnostic = checker.report_diagnostic( FirstWordUncapitalized { first_word: first_word.to_string(), - capitalized_word: capitalized_word.to_string(), + capitalized_word: capitalized_word.clone(), }, docstring.range(), ); diff --git a/crates/ruff_linter/src/rules/refurb/rules/bit_count.rs b/crates/ruff_linter/src/rules/refurb/rules/bit_count.rs index b86c6e9d9e..0690ca5449 100644 --- a/crates/ruff_linter/src/rules/refurb/rules/bit_count.rs +++ b/crates/ruff_linter/src/rules/refurb/rules/bit_count.rs @@ -188,7 +188,7 @@ pub(crate) fn bit_count(checker: &Checker, call: &ExprCall) { let mut diagnostic = checker.report_diagnostic( BitCount { existing: SourceCodeSnippet::from_str(literal_text), - replacement: SourceCodeSnippet::new(replacement.to_string()), + replacement: SourceCodeSnippet::new(replacement.clone()), }, call.range(), ); diff --git a/crates/ruff_python_formatter/src/lib.rs b/crates/ruff_python_formatter/src/lib.rs index e6b2f9e7b8..bf68598e13 100644 --- a/crates/ruff_python_formatter/src/lib.rs +++ b/crates/ruff_python_formatter/src/lib.rs @@ -334,7 +334,7 @@ class A: ... let options = PyFormatOptions::from_source_type(source_type); let printed = format_range(&source, TextRange::new(start, end), options).unwrap(); - let mut formatted = source.to_string(); + let mut formatted = source.clone(); formatted.replace_range( std::ops::Range::::from(printed.source_range()), printed.as_code(), diff --git a/crates/ty_python_semantic/src/python_platform.rs b/crates/ty_python_semantic/src/python_platform.rs index b21424ee33..04f7fa3598 100644 --- a/crates/ty_python_semantic/src/python_platform.rs +++ b/crates/ty_python_semantic/src/python_platform.rs @@ -24,7 +24,7 @@ impl From for PythonPlatform { fn from(platform: String) -> Self { match platform.as_str() { "all" => PythonPlatform::All, - _ => PythonPlatform::Identifier(platform.to_string()), + _ => PythonPlatform::Identifier(platform.clone()), } } } diff --git a/crates/ty_python_semantic/src/semantic_index/use_def.rs b/crates/ty_python_semantic/src/semantic_index/use_def.rs index 39f3a1a8ec..dcca102b87 100644 --- a/crates/ty_python_semantic/src/semantic_index/use_def.rs +++ b/crates/ty_python_semantic/src/semantic_index/use_def.rs @@ -233,7 +233,7 @@ //! have two live bindings of `x`: `x = 3` and `x = 4`. //! //! Another piece of information that the `UseDefMap` needs to provide are reachability constraints. -//! See [`reachability_constraints.rs`] for more details, in particular how they apply to bindings. +//! See `reachability_constraints.rs` for more details, in particular how they apply to bindings. //! //! The [`UseDefMapBuilder`] itself just exposes methods for taking a snapshot, resetting to a //! snapshot, and merging a snapshot into the current state. The logic using these methods lives in diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 73328e053b..1a35d66439 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.90" +channel = "1.91"