Skip to content

fix: Use ident span when recovering comments in non-shorthand PatField - #7004

Merged
jieyouxu merged 1 commit into
rust-lang:mainfrom
ytmimi:issue_6984
Aug 11, 2026
Merged

fix: Use ident span when recovering comments in non-shorthand PatField#7004
jieyouxu merged 1 commit into
rust-lang:mainfrom
ytmimi:issue_6984

Conversation

@ytmimi

@ytmimi ytmimi commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Fixes #6984

Using the pat span wasn't correct because it contained the field identifier, which caused code duplication when recovering comments between the attribute and the pattern struct field.

…ield`

Fixes 6984

Using the `pat` span wasn't correct because it contained the field identifier,
which caused code duplication when recovering comments between the attribute and
the pattern struct field.
@rustbot rustbot added the S-waiting-on-review Status: awaiting review from the assignee but also interested parties. label Aug 1, 2026
Comment on lines +5 to +7
#[cfg(feature = "diagnostics")]
// comment between attribute and field
field_name_baz: _,

@ytmimi ytmimi Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Pre-existing indent bug for style_edition <= 2024. Adding this test case to show that code duplication is avoided in earlier style editions.

View changes since the review

@jieyouxu jieyouxu self-assigned this Aug 11, 2026

@jieyouxu jieyouxu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@jieyouxu jieyouxu added the F-impacts-stable-but-broken-formatting Expected formatting impact: affects stable formatting but where broken code was produced label Aug 11, 2026
@jieyouxu
jieyouxu added this pull request to the merge queue Aug 11, 2026
Merged via the queue into rust-lang:main with commit 936b23e Aug 11, 2026
27 checks passed
@rustbot rustbot added release-notes Needs an associated changelog entry and removed S-waiting-on-review Status: awaiting review from the assignee but also interested parties. labels Aug 11, 2026
@ytmimi
ytmimi deleted the issue_6984 branch August 11, 2026 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-impacts-stable-but-broken-formatting Expected formatting impact: affects stable formatting but where broken code was produced release-notes Needs an associated changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Comment between a #[cfg] attribute and a non-shorthand struct-pattern field duplicates the field identifier

3 participants