Skip to content

Commit 4c73fb9

Browse files
committed
lint: upgrade perfectionist to 0.0.0-rc.21
`0.0.0-rc.21` replaces `import_grouping_mismatch`'s `separate_reexports` boolean with a mandatory `reexports` enum (KSXGitHub/perfectionist#335), implementing the alias-vs-submodule re-export split requested in #443. - Set `reexports = "split"` so submodule re-exports (`pub use child::Item;`) sit above alias re-exports (`pub use Item as Alias;`) in their own blank-separated blocks. Reorganize the three modules that mix both kinds (`data_tree`, `hardlink_list`, `link_path_list`). - Update `CONTRIBUTING.md` to describe the split layout. https://claude.ai/code/session_016ZyYFnzSv876usUHLEX4qe
1 parent 1858a9c commit 4c73fb9

5 files changed

Lines changed: 17 additions & 15 deletions

File tree

CONTRIBUTING.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,32 +39,30 @@ Automated tools enforce formatting (`cargo fmt`), linting (`cargo clippy`), and
3939
Two `perfectionist` rules govern imports automatically:
4040

4141
- `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. 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`).
42+
- `perfectionist::import_grouping_mismatch`, configured for the `single_block` style with `reexports = "split"`, controls how `use` statements are partitioned into blocks. Private imports sit in one contiguous block with no blank lines between them. `pub use` re-exports lead, split into two blank-separated sub-blocks: submodule re-exports (a multi-segment path such as `pub use child::Item;`) above alias re-exports (a single-segment path such as `pub use Item as Alias;`).
4343

4444
Import ordering within the block is enforced separately by `cargo fmt`.
4545

4646
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.
4747

4848
```rust
49-
pub use sub::Sub;
49+
pub use iter::Iter;
50+
pub use reflection::Reflection;
51+
52+
pub use Reflection as ListReflection;
5053

51-
use crate::args::{Args, Quantity, Threads};
52-
use crate::bytes_format::BytesFormat;
5354
use crate::size;
54-
use clap::Parser;
55-
use pipe_trait::Pipe;
56-
use std::io::stdin;
57-
use std::time::Duration;
55+
use std::path::PathBuf;
5856

5957
#[cfg(unix)]
60-
use crate::get_size::{GetBlockCount, GetBlockSize};
58+
use std::os::unix::fs::MetadataExt;
6159
```
6260

6361
### Module Organization
6462

6563
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:
6664

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.
65+
- List `pub mod` declarations first, then the `pub use` re-exports, then the private `use` block, then the remaining items. `perfectionist::import_grouping_mismatch` (`reexports = "split"`) keeps re-exports above the private imports, split into a submodule-re-export block and an alias-re-export block, and `cargo fmt` sorts within each block.
6866
- Use `pub use` to re-export key types at the module level for convenience.
6967

7068
```rust

dylint.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[workspace.metadata.dylint]
22
libraries = [
3-
{ git = "https://github.com/KSXGitHub/perfectionist", tag = "0.0.0-rc.20" },
3+
{ git = "https://github.com/KSXGitHub/perfectionist", tag = "0.0.0-rc.21" },
44
]
55

66
[perfectionist]
@@ -30,6 +30,7 @@ style = "module"
3030

3131
["perfectionist::import_grouping_mismatch"]
3232
style = "single_block"
33+
reexports = "split"
3334

3435
["perfectionist::impure_macro_arguments"]
3536
deny_extra = ["debug_assert_op", "debug_assert_op_expr"]

src/data_tree.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
pub mod reflection;
22

3-
pub use Reflection as DataTreeReflection;
43
pub use reflection::Reflection;
54

5+
pub use Reflection as DataTreeReflection;
6+
67
use super::size;
78

89
/// Disk usage data of a filesystem tree.

src/hardlink/hardlink_list.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ pub mod iter;
22
pub mod reflection;
33
pub mod summary;
44

5-
pub use Reflection as HardlinkListReflection;
6-
pub use Summary as SharedLinkSummary;
75
pub use iter::Iter;
86
pub use reflection::Reflection;
97
pub use summary::Summary;
108

9+
pub use Reflection as HardlinkListReflection;
10+
pub use Summary as SharedLinkSummary;
11+
1112
use crate::device::DeviceNumber;
1213
use crate::hardlink::LinkPathList;
1314
use crate::inode::InodeNumber;

src/hardlink/link_path_list.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
mod iter;
22
mod reflection;
33

4-
pub use Reflection as LinkPathListReflection;
54
pub use iter::Iter;
65
pub use reflection::Reflection;
76

7+
pub use Reflection as LinkPathListReflection;
8+
89
use std::path::PathBuf;
910

1011
/// List of different hardlinks to the same file.

0 commit comments

Comments
 (0)