Add documented struct field spacing option#6926
Closed
joshka wants to merge 1 commit into
Closed
Conversation
Add unstable rustfmt options for inserting blank lines around contiguous documented struct field sections. Use a Preserve/Always/Threshold mode instead of overloading a numeric sentinel, and evaluate Threshold against the total field count of the struct. This keeps the configuration aligned with existing rustfmt option patterns and avoids ambiguous 0/1 threshold semantics. Document the behavior and add focused formatter fixtures for Preserve, Always, and threshold boundary cases.
Contributor
|
Closing since we're not moving forward with the feature request at this time. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6925.
Summary
Add unstable rustfmt options for inserting blank lines around documented struct field sections:
documented_struct_field_blank_lines = "Preserve" | "Always" | "Threshold"documented_struct_field_blank_lines_threshold = <usize>This follows existing rustfmt config patterns better than overloading a single numeric option with a sentinel value.
Testing
cargo test --lib test_dump_default_config -- --nocapturecargo test --lib test_dump_style_edition_2024_config -- --nocapturecargo test --lib verify_config_test_names -- --nocapturecargo test --lib configuration_snippet_tests -- --nocapturecargo test --lib system_tests -- --nocaptureImplementation notes
ListItem::new_linesin the vertical field formatter instead of introducing a second spacing path.Open points / context
0and1, especially if0was treated as eitherPreserveorAlways. The enum mode avoids that ambiguity.#[rustfmt::skip]or intervening non-doc comments inside documented sections; those continue to follow the existing contiguous-section logic invertical.rs.AI disclosure
This PR was developed with assistance from Codex using GPT-5.5.