Skip to content
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

Preserve normalized comments after last list item #5091

Merged

Conversation

mujpao
Copy link
Contributor

@mujpao mujpao commented Nov 18, 2021

Fixes #4909

This issue was that a multi-line comment starting on a new line after the last item of a list is considered a post-comment.
This adds a check for whether a post-comment in a list starts with a newline and doesn't force the comment to become a block comment in that case.

Copy link
Member

@calebcartwright calebcartwright left a comment

Choose a reason for hiding this comment

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

Fix LGTM, thank you! Couple minor changes/extensions requested on the tests.

One left inline, but GitHub is being weird and won't let me add other inline comments, so wanted to ask that the empty enum and struct (E2 and S2) be decorated in some way to denote the incorrect indentation of the second line in each is due to the bug described in #4854 as opposed to expected/desired behavior.

Adding a comment to that effect will be helpful for someone in the future once #4854 is fixed so they know they can safely update those lines in these tests

@@ -0,0 +1,70 @@
// rustfmt-normalize_comments: true

Copy link
Member

Choose a reason for hiding this comment

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

There was a comment reported on the linked issue that the same symptoms were observed with wrap_comments as well. Would you mind also checking if the original behavior can be reproduced with wrap_comments, and if so, whether that's also resolved with your fix (and include a test with wrap_comments too 🙏)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the issue was present with wrap_comments too. I added more tests now.

Copy link
Member

Choose a reason for hiding this comment

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

Fantastic! One last thing 😄 would you mind restructuring the tests to have separate pairs with wrap_comments and normalize_comments set in isolation of each other?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ohh I didn't realize it was also happening with wrap_comments in isolation. I will add another test.

@mujpao mujpao force-pushed the fix-denormalizes-some-comments branch from e3ab83e to 47a6dca Compare November 19, 2021 01:07
@calebcartwright
Copy link
Member

That'll work thank you! I suspect there's probably at least one duplicate report #4909 somewhere in the issue backlog. If you find yourself really bored and willing to search for any other issues that are now fixed by your changes that'd be great (no worries if not though)

@calebcartwright calebcartwright merged commit 196e676 into rust-lang:master Nov 20, 2021
@mujpao
Copy link
Contributor Author

mujpao commented Nov 22, 2021

It looks like #4430 and #4420 are fixed by the changes.

@calebcartwright
Copy link
Member

Awesome, thanks so much for checking! Would you be willing/interested in opening another PR that adds respective test cases for those issues?

@mujpao
Copy link
Contributor Author

mujpao commented Nov 23, 2021

Sure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

normalize_comments = true de-normalizes some comments
2 participants