From cfaf87893a5809f67e8fc9953327f4e8a5e4ce0e Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Fri, 2 Jun 2023 11:43:16 +0200 Subject: [PATCH] Discard changes to crates/ruff_formatter/src/lib.rs --- crates/ruff_formatter/src/lib.rs | 5 +---- crates/ruff_python_formatter/src/builders.rs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/crates/ruff_formatter/src/lib.rs b/crates/ruff_formatter/src/lib.rs index b02a5d50ddb73..a5e9401412433 100644 --- a/crates/ruff_formatter/src/lib.rs +++ b/crates/ruff_formatter/src/lib.rs @@ -518,10 +518,7 @@ impl Format for () { /// /// That's why the `ruff_js_formatter` crate must define a new-type that implements the formatting /// of `JsIfStatement`. -pub trait FormatRule -where - T: ?Sized, -{ +pub trait FormatRule { fn fmt(&self, item: &T, f: &mut Formatter) -> FormatResult<()>; } diff --git a/crates/ruff_python_formatter/src/builders.rs b/crates/ruff_python_formatter/src/builders.rs index 64722deb22133..7d859789fd859 100644 --- a/crates/ruff_python_formatter/src/builders.rs +++ b/crates/ruff_python_formatter/src/builders.rs @@ -5,7 +5,7 @@ use ruff_formatter::write; use rustpython_parser::ast::Ranged; /// Provides Python specific extensions to [`Formatter`]. -pub(crate) trait PyFormatterExtensions<'buf, 'context> { +pub(crate) trait PyFormatterExtensions<'context, 'buf> { /// Creates a joiner that inserts the appropriate number of empty lines between two nodes, depending on the /// line breaks that separate the two nodes in the source document. The `level` customizes the maximum allowed /// empty lines between any two nodes. Separates any two nodes by at least a hard line break. @@ -14,28 +14,28 @@ pub(crate) trait PyFormatterExtensions<'buf, 'context> { /// * [`NodeLevel::Statement`]: Up to one empty line /// * [`NodeLevel::Parenthesized`]: No empty lines fn join_nodes<'fmt>(&'fmt mut self, level: NodeLevel) - -> JoinNodesBuilder<'fmt, 'buf, 'context>; + -> JoinNodesBuilder<'fmt, 'context, 'buf>; } -impl<'buf, 'context> PyFormatterExtensions<'buf, 'context> for PyFormatter<'buf, 'context> { +impl<'buf, 'context> PyFormatterExtensions<'context, 'buf> for PyFormatter<'context, 'buf> { fn join_nodes<'fmt>( &'fmt mut self, level: NodeLevel, - ) -> JoinNodesBuilder<'fmt, 'buf, 'context> { + ) -> JoinNodesBuilder<'fmt, 'context, 'buf> { JoinNodesBuilder::new(self, level) } } #[must_use = "must eventually call `finish()` on the builder."] -pub(crate) struct JoinNodesBuilder<'fmt, 'buf, 'context> { - fmt: &'fmt mut PyFormatter<'buf, 'context>, +pub(crate) struct JoinNodesBuilder<'fmt, 'context, 'buf> { + fmt: &'fmt mut PyFormatter<'context, 'buf>, result: FormatResult<()>, has_elements: bool, node_level: NodeLevel, } -impl<'fmt, 'buf, 'context> JoinNodesBuilder<'fmt, 'buf, 'context> { - fn new(fmt: &'fmt mut PyFormatter<'buf, 'context>, level: NodeLevel) -> Self { +impl<'fmt, 'context, 'buf> JoinNodesBuilder<'fmt, 'context, 'buf> { + fn new(fmt: &'fmt mut PyFormatter<'context, 'buf>, level: NodeLevel) -> Self { Self { fmt, result: Ok(()),