Skip to content

Struct fields: avoid stripping comments in parentheses - #7168

Draft
matthewhughes934 wants to merge 1 commit into
rust-lang:mainfrom
matthewhughes934:comments-in-struct-fields
Draft

matthewhughes934 wants to merge 1 commit into
rust-lang:mainfrom
matthewhughes934:comments-in-struct-fields

Conversation

@matthewhughes934

Copy link
Copy Markdown
Contributor

This goes part way to address[1]. The comments are only preserved When there's a type in the field, this doesn't address empty parenthesis being strip of comments, e.g. the following formatting still occurs:

field: (/* some comment*/) -> field: ()

I was looking for a generic 'add this comment alongside this other content' function but couldn't find one, so I've tried to add one that I'm hoping can be of general use.

References: #6642 [1]

  • I did not use an LLM to create a change in this PR.
  • I used an LLM to create a change in this PR, and I have explained below how it was used.

This goes part way to address[1]. The comments are only preserved When
there's a type in the field, this doesn't address empty parenthesis
being strip of comments, e.g. the following formatting still occurs:

    field: (/* some comment*/) -> field: ()

I was looking for a generic 'add this comment alongside this other
content' function but couldn't find one, so I've tried to add one that
I'm hoping can be of general use.

References: rust-lang#6642 [1]
@rustbot rustbot added the S-waiting-on-author Status: awaiting some action (such as code changes or more information) from the author. label Oct 8, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: awaiting some action (such as code changes or more information) from the author.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants