-
Notifications
You must be signed in to change notification settings - Fork 902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Treat empty doc comments that precede doc attributes as significant #5098
base: master
Are you sure you want to change the base?
Conversation
Fixes 5073 Normally we would want to remove any empty trailing doc comments however, as highlighted by 5073 by removing these trailing comments rustfmt is interfering with tools like rustdoc. Checks have been added to allow rustfmt to keep empty trailing comments when using ``wrap_comments = true`` if and only if the empty trailing comments immideatly precede a doc attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decent number of signatures and associated call sites needed to be updated but guess that"s not all that surprising given the pain of working with comments in general, so this works for me.
One minor thing, then content moving ahead to resolve the reported issue
@@ -0,0 +1,7 @@ | |||
// rustfmt-wrap_comments: false | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit but could you fix the typo in these file names? *_commet_*
-> *_comment_*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely not a nit at all! I appreciate you pointing this out and I"ll get to fixing it!
I agree there were a few signatures that needed to change. As you might tell from the code I was trying to find a way to dynamically determine if empty comments were significant. I"m definitely not married to this solution and open to suggestions you might have on how to fix this. That being said, it"s been a while since I submitted this PR, and revisiting this now has got me wondering if a simpler approach would be to introduce a new unstable configuration option like |
While that does sound like it"d make for a simpler implementation, do you think the categorical behavior associated with a config option will give users what they need in all contexts? My concern would be that the answer genuinely seems like "it depends" which is impossible to handle with a boolean-style config option, and I worry that an enum-style option would be challenging as well (what would the variants and their behaviors be?) |
I think that"s a really good point. Let me think on this a bit and get back to you. To your point, it might be better to avoid going down the configuration option route, but part of me still thinks I can come up with a slightly cleaner way to handle this. |
Fixes #5073
Normally we would want to remove any empty trailing doc comments
however, as highlighted by 5073 by removing these trailing comments
rustfmt is interfering with tools like rustdoc.
Checks have been added to allow rustfmt to keep empty trailing comments
when using
wrap_comments = true
if and only if the empty trailingcomments immideatly precede a doc attribute.