## Summary This PR runs `rustfmt` with a few nightly options as a one-time fix to catch some malformatted comments. I ended up just running with: ```toml condense_wildcard_suffixes = true edition = "2021" max_width = 100 normalize_comments = true normalize_doc_attributes = true reorder_impl_items = true unstable_features = true use_field_init_shorthand = true ``` Since these all seem like reasonable things to fix, so may as well while I'm here.
40 lines
1.2 KiB
Rust
40 lines
1.2 KiB
Rust
use crate::context::PyFormatContext;
|
|
use crate::{AsFormat, IntoFormat, PyFormatter};
|
|
use ruff_formatter::{Format, FormatOwnedWithRule, FormatRefWithRule, FormatResult, FormatRule};
|
|
use rustpython_parser::ast::Mod;
|
|
|
|
pub(crate) mod mod_expression;
|
|
pub(crate) mod mod_function_type;
|
|
pub(crate) mod mod_interactive;
|
|
pub(crate) mod mod_module;
|
|
|
|
#[derive(Default)]
|
|
pub struct FormatMod;
|
|
|
|
impl FormatRule<Mod, PyFormatContext<'_>> for FormatMod {
|
|
fn fmt(&self, item: &Mod, f: &mut PyFormatter) -> FormatResult<()> {
|
|
match item {
|
|
Mod::Module(x) => x.format().fmt(f),
|
|
Mod::Interactive(x) => x.format().fmt(f),
|
|
Mod::Expression(x) => x.format().fmt(f),
|
|
Mod::FunctionType(x) => x.format().fmt(f),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl<'ast> AsFormat<PyFormatContext<'ast>> for Mod {
|
|
type Format<'a> = FormatRefWithRule<'a, Mod, FormatMod, PyFormatContext<'ast>>;
|
|
|
|
fn format(&self) -> Self::Format<'_> {
|
|
FormatRefWithRule::new(self, FormatMod::default())
|
|
}
|
|
}
|
|
|
|
impl<'ast> IntoFormat<PyFormatContext<'ast>> for Mod {
|
|
type Format = FormatOwnedWithRule<Mod, FormatMod, PyFormatContext<'ast>>;
|
|
|
|
fn into_format(self) -> Self::Format {
|
|
FormatOwnedWithRule::new(self, FormatMod::default())
|
|
}
|
|
}
|