You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`0.0.0-rc.20` adds `separate_reexports` to `import_grouping_mismatch`
(KSXGitHub/perfectionist#325) and corrects `clap_help_markdown`'s false
positives on `ValueEnum` docs (KSXGitHub/perfectionist#326).
- `separate_reexports` (default `true`) keeps `pub use` re-exports in
their own leading block natively, so the 11 per-file
`#[expect(perfectionist::import_grouping_mismatch)]` suppressions are
deleted and the integration tests' `pub use _utils::*` re-exports are
separated from their private imports. Closes#442.
- The `clap_help_markdown` correction leaves a `ValueEnum`'s enum-level
doc alone and recognises `#[cfg_attr(<cfg>, clap(help = ...))]`
overrides, so the `BytesFormat` suppression is deleted. Closes#441.
https://claude.ai/code/session_016ZyYFnzSv876usUHLEX4qe
Two `perfectionist` rules govern imports automatically:
40
40
41
41
-`perfectionist::import_granularity_mismatch`, configured for the `module` style, controls how items are merged within each `use` statement. Items from the same module are merged into a single braced `use` statement, while each module keeps its own `use` statement rather than collapsing an entire crate into one nested-braces statement.
42
-
-`perfectionist::import_grouping_mismatch`, configured for the `single_block` style, controls how `use` statements are partitioned into blocks. Every `use` statement, whether a `pub use` re-export or a private import, sits in one contiguous block with no blank lines between them.
42
+
-`perfectionist::import_grouping_mismatch`, configured for the `single_block` style, controls how `use` statements are partitioned into blocks. Private imports sit in one contiguous block with no blank lines between them, while `pub use` re-exports are pulled into their own leading block, separated by a blank line (the rule's default `separate_reexports = true`).
43
43
44
44
Import ordering within the block is enforced separately by `cargo fmt`.
45
45
46
46
Imports gated by a platform or feature attribute such as `#[cfg(unix)]` are kept in their own block after the main imports, separated by a blank line. Under `single_block` the rule recognizes this trailing `#[cfg]` block automatically through its default `cfg_block_handling = "trailing"`, so no manual exception is required.
47
47
48
48
```rust
49
+
pubusesub::Sub;
50
+
49
51
usecrate::args::{Args, Quantity, Threads};
50
52
usecrate::bytes_format::BytesFormat;
51
53
usecrate::size;
@@ -62,7 +64,7 @@ use crate::get_size::{GetBlockCount, GetBlockSize};
62
64
63
65
The flat file pattern (`module.rs` rather than `module/mod.rs`) is enforced by `clippy::mod_module_files`, enabled in `Cargo.toml`. Earlier releases relied on a `perfectionist::flat_module_pattern` rule; `perfectionist``0.0.0-rc.19` removed it in favor of the equivalent Clippy lint. In addition to that requirement, follow these conventions:
64
66
65
-
- List `pub mod` declarations first, followed by the `use`block, then the remaining items. The `use` block holds both `pub use` re-exports and private imports; `cargo fmt` and `perfectionist::import_grouping_mismatch`keep them in one sorted group, so do not rely on a fixed order between the two kinds.
67
+
- List `pub mod` declarations first, then the `pub use`re-exports in their own group, then the private `use` block, then the remaining items. `perfectionist::import_grouping_mismatch`(`separate_reexports`) keeps the re-exports in a block of their own above the private imports, and `cargo fmt` sorts within each block.
66
68
- Use `pub use` to re-export key types at the module level for convenience.
0 commit comments