Skip to content

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

Open
ytmimi wants to merge 1 commit into
rust-lang:mainfrom
ytmimi:issue_6984
Open

fix: Use ident span when recovering comments in non-shorthand PatField#7004
ytmimi wants to merge 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

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.

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

2 participants