Skip to content

Commit 8c7b280

Browse files
committed
lint: upgrade perfectionist to 0.0.0-rc.20
`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
1 parent 96608ea commit 8c7b280

22 files changed

Lines changed: 14 additions & 98 deletions

CONTRIBUTING.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,15 @@ 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. 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`).
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;
50+
4951
use crate::args::{Args, Quantity, Threads};
5052
use crate::bytes_format::BytesFormat;
5153
use crate::size;
@@ -62,7 +64,7 @@ use crate::get_size::{GetBlockCount, GetBlockSize};
6264

6365
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:
6466

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.
6668
- Use `pub use` to re-export key types at the module level for convenience.
6769

6870
```rust

dylint.toml

Lines changed: 1 addition & 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.19" },
3+
{ git = "https://github.com/KSXGitHub/perfectionist", tag = "0.0.0-rc.20" },
44
]
55

66
[perfectionist]

src/app.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
#![cfg_attr(
2-
dylint_lib = "perfectionist",
3-
expect(
4-
perfectionist::import_grouping_mismatch,
5-
reason = "pub use re-exports are kept in their own group; see #442"
6-
)
7-
)]
8-
91
pub mod sub;
102

113
pub use sub::Sub;

src/args.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
#![cfg_attr(
2-
dylint_lib = "perfectionist",
3-
expect(
4-
perfectionist::import_grouping_mismatch,
5-
reason = "pub use re-exports are kept in their own group; see #442"
6-
)
7-
)]
8-
91
pub mod depth;
102
pub mod fraction;
113
pub mod quantity;

src/bytes_format.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
#![cfg_attr(
2-
dylint_lib = "perfectionist",
3-
expect(
4-
perfectionist::import_grouping_mismatch,
5-
reason = "pub use re-exports are kept in their own group; see #442"
6-
)
7-
)]
8-
91
pub mod formatter;
102
pub mod output;
113
pub mod parsed_value;
@@ -23,13 +15,6 @@ use clap::ValueEnum;
2315
/// The [`DisplayFormat`](crate::size::Size::DisplayFormat) type of [`Bytes`](crate::size::Bytes).
2416
#[derive(Debug, Clone, Copy)]
2517
#[cfg_attr(feature = "cli", derive(ValueEnum))]
26-
#[cfg_attr(
27-
dylint_lib = "perfectionist",
28-
expect(
29-
perfectionist::clap_help_markdown,
30-
reason = "the enum-level doc is never used as --help text, and the variant docs are overridden by an explicit clap(help = ...); see issue #441"
31-
)
32-
)]
3318
pub enum BytesFormat {
3419
/// Display the value as-is.
3520
#[cfg_attr(

src/data_tree.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
#![cfg_attr(
2-
dylint_lib = "perfectionist",
3-
expect(
4-
perfectionist::import_grouping_mismatch,
5-
reason = "pub use re-exports are kept in their own group; see #442"
6-
)
7-
)]
8-
91
pub mod reflection;
102

113
pub use Reflection as DataTreeReflection;

src/hardlink/hardlink_list.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
#![cfg_attr(
2-
dylint_lib = "perfectionist",
3-
expect(
4-
perfectionist::import_grouping_mismatch,
5-
reason = "pub use re-exports are kept in their own group; see #442"
6-
)
7-
)]
8-
91
pub mod iter;
102
pub mod reflection;
113
pub mod summary;

src/hardlink/link_path_list.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
#![cfg_attr(
2-
dylint_lib = "perfectionist",
3-
expect(
4-
perfectionist::import_grouping_mismatch,
5-
reason = "pub use re-exports are kept in their own group; see #442"
6-
)
7-
)]
8-
91
mod iter;
102
mod reflection;
113

src/json_data.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
#![cfg_attr(
2-
dylint_lib = "perfectionist",
3-
expect(
4-
perfectionist::import_grouping_mismatch,
5-
reason = "pub use re-exports are kept in their own group; see #442"
6-
)
7-
)]
8-
91
pub mod binary_version;
102
pub mod schema_version;
113

src/reporter.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
#![cfg_attr(
2-
dylint_lib = "perfectionist",
3-
expect(
4-
perfectionist::import_grouping_mismatch,
5-
reason = "pub use re-exports are kept in their own group; see #442"
6-
)
7-
)]
8-
91
pub mod error_only_reporter;
102
pub mod error_report;
113
pub mod event;

0 commit comments

Comments
 (0)