diff --git a/Cargo.lock b/Cargo.lock index 6629193df54cd7..544acbc15a1138 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2764,7 +2764,7 @@ dependencies = [ "insta", "once_cell", "rome_formatter", - "rome_rowan", + "rome_text_size", "rustc-hash", "rustpython-ast 0.2.0 (git+/~https://github.com/RustPython/RustPython.git?rev=4f38cb68e4a97aeea9eb19673803a0bd5f655383)", "rustpython-common 0.2.0 (git+/~https://github.com/RustPython/RustPython.git?rev=4f38cb68e4a97aeea9eb19673803a0bd5f655383)", diff --git a/crates/ruff_fmt/Cargo.toml b/crates/ruff_fmt/Cargo.toml index ff84456f064696..87948c096de188 100644 --- a/crates/ruff_fmt/Cargo.toml +++ b/crates/ruff_fmt/Cargo.toml @@ -9,7 +9,7 @@ clap = { version = "4.0.1", features = ["derive"] } insta = { version = "1.19.1", features = ["yaml"] } once_cell = "1.17.0" rome_formatter = { path = "../../../tools/crates/rome_formatter" } -rome_rowan = { path = "../../../tools/crates/rome_rowan" } +rome_text_size = { path = "../../../tools/crates/rome_text_size" } rustc-hash = "1.1.0" rustpython-ast = { git = "/~https://github.com/RustPython/RustPython.git", rev = "4f38cb68e4a97aeea9eb19673803a0bd5f655383" } rustpython-common = { git = "/~https://github.com/RustPython/RustPython.git", rev = "4f38cb68e4a97aeea9eb19673803a0bd5f655383" } diff --git a/crates/ruff_fmt/src/format/alias.rs b/crates/ruff_fmt/src/format/alias.rs index a5246f748bfe4c..72bc5c61764513 100644 --- a/crates/ruff_fmt/src/format/alias.rs +++ b/crates/ruff_fmt/src/format/alias.rs @@ -1,6 +1,6 @@ use rome_formatter::prelude::*; use rome_formatter::write; -use rome_rowan::TextSize; +use rome_text_size::TextSize; use crate::context::ASTFormatContext; use crate::cst::Alias; diff --git a/crates/ruff_fmt/src/format/arg.rs b/crates/ruff_fmt/src/format/arg.rs index 063e890cc478a4..b4d31687a59d6e 100644 --- a/crates/ruff_fmt/src/format/arg.rs +++ b/crates/ruff_fmt/src/format/arg.rs @@ -1,6 +1,6 @@ use rome_formatter::prelude::*; use rome_formatter::write; -use rome_rowan::TextSize; +use rome_text_size::TextSize; use crate::context::ASTFormatContext; use crate::cst::Arg; diff --git a/crates/ruff_fmt/src/format/builders.rs b/crates/ruff_fmt/src/format/builders.rs index ea9175d706979e..16dd894dc3225a 100644 --- a/crates/ruff_fmt/src/format/builders.rs +++ b/crates/ruff_fmt/src/format/builders.rs @@ -1,6 +1,6 @@ use rome_formatter::prelude::*; use rome_formatter::{write, Format}; -use rome_rowan::TextSize; +use rome_text_size::TextSize; use crate::context::ASTFormatContext; use crate::cst::Stmt; diff --git a/crates/ruff_fmt/src/format/expr.rs b/crates/ruff_fmt/src/format/expr.rs index 29f31993d7c5d9..f9d050a86ccbc4 100644 --- a/crates/ruff_fmt/src/format/expr.rs +++ b/crates/ruff_fmt/src/format/expr.rs @@ -2,7 +2,7 @@ use rome_formatter::prelude::*; use rome_formatter::{format_args, write}; -use rome_rowan::TextSize; +use rome_text_size::TextSize; use rustpython_ast::Constant; use crate::builders::literal; diff --git a/crates/ruff_fmt/src/format/stmt.rs b/crates/ruff_fmt/src/format/stmt.rs index e577cb4854076c..258ca264d19405 100644 --- a/crates/ruff_fmt/src/format/stmt.rs +++ b/crates/ruff_fmt/src/format/stmt.rs @@ -2,7 +2,7 @@ use rome_formatter::prelude::*; use rome_formatter::{format_args, write}; -use rome_rowan::TextSize; +use rome_text_size::TextSize; use crate::builders::literal; use crate::context::ASTFormatContext; diff --git a/crates/ruff_fmt/src/lib.rs b/crates/ruff_fmt/src/lib.rs index 95680df20ef45c..cb8a548b55061a 100644 --- a/crates/ruff_fmt/src/lib.rs +++ b/crates/ruff_fmt/src/lib.rs @@ -35,7 +35,7 @@ pub fn fmt(contents: &str) -> Result { let python_ast = rustpython_helpers::parse_program_tokens(tokens, "")?; // Convert to a CST. - let mut python_cst: Vec = python_ast.into_iter().map(Into::into).collect::>(); + let mut python_cst: Vec = python_ast.into_iter().map(Into::into).collect(); // Attach trivia. attach(&mut python_cst, trivia); diff --git a/crates/ruff_fmt/src/shared_traits.rs b/crates/ruff_fmt/src/shared_traits.rs index c91294699af8e4..65fe527fa32f6a 100644 --- a/crates/ruff_fmt/src/shared_traits.rs +++ b/crates/ruff_fmt/src/shared_traits.rs @@ -22,25 +22,6 @@ where } } -/// Implement [`AsFormat`] for [`SyntaxResult`] where `T` implements -/// [`AsFormat`]. -/// -/// Useful to format mandatory AST fields without having to unwrap the value -/// first. -impl AsFormat for rome_rowan::SyntaxResult -where - T: AsFormat, -{ - type Format<'a> = rome_rowan::SyntaxResult> where Self: 'a; - - fn format(&self) -> Self::Format<'_> { - match self { - Ok(value) => Ok(value.format()), - Err(err) => Err(*err), - } - } -} - /// Implement [`AsFormat`] for [`Option`] when `T` implements [`AsFormat`] /// /// Allows to call format on optional AST fields without having to unwrap the @@ -65,17 +46,6 @@ pub trait IntoFormat { fn into_format(self) -> Self::Format; } -impl IntoFormat for rome_rowan::SyntaxResult -where - T: IntoFormat, -{ - type Format = rome_rowan::SyntaxResult; - - fn into_format(self) -> Self::Format { - self.map(IntoFormat::into_format) - } -} - /// Implement [`IntoFormat`] for [`Option`] when `T` implements [`IntoFormat`] /// /// Allows to call format on optional AST fields without having to unwrap the