Skip to content

fix: Fmt struct field patters with cfgs - #6983

Open
kostekIV wants to merge 2 commits into
rust-lang:mainfrom
kostekIV:cfg-in-struct
Open

fix: Fmt struct field patters with cfgs#6983
kostekIV wants to merge 2 commits into
rust-lang:mainfrom
kostekIV:cfg-in-struct

Conversation

@kostekIV

Copy link
Copy Markdown

Fixes

#5982 and #5920.

Desription

the non-shorthand branch passed the block-indented nested_shape to combine_strs_with_missing_comments. That call decides where the whole field lands relative to its attribute, so it should use the field's own shape (exactly as the shorthand branch already does.

Question

Not sure if this change requires the edition gate or not? As a default I have gated it behind 2027 edition.

@rustbot rustbot added the S-waiting-on-review Status: awaiting review from the assignee but also interested parties. label Jul 27, 2026
// The same, but with leading comments on the fields.
fn example_with_comments() {
let Foo {
// comment on shorthand field

@kostekIV kostekIV Jul 27, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

above the cfg because of this issue I encountered while fixing this issue - #6984

View changes since the review

@ytmimi ytmimi self-assigned this Jul 27, 2026

@ytmimi ytmimi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall the change looks correct to me. Just want to break out the tests

View changes since this review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's create two different test files. One for #5982 and the other for #5920

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread src/patterns.rs
Comment on lines +472 to +476
let combine_shape = if context.config.style_edition() >= StyleEdition::Edition2027 {
shape
} else {
nested_shape
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this change would need to be gated.

@rustbot rustbot added S-waiting-on-author Status: awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: awaiting review from the assignee but also interested parties. labels Jul 27, 2026
@rustbot

rustbot commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@kostekIV

Copy link
Copy Markdown
Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: awaiting some action (such as code changes or more information) from the author. labels Jul 27, 2026
@kostekIV
kostekIV requested a review from ytmimi July 29, 2026 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants