Skip to content

Fixed 'Comment removed between type name and =' issue #4448

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 5 commits into from
Oct 9, 2020

Conversation

whizsid
Copy link
Contributor

@whizsid whizsid commented Oct 2, 2020

Fixes #4244 .

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.

Thanks @whizsid! This is a good starting point but we'll need to iterate on it a bit to cover other scenarios. Inline feedback left for your review

@whizsid
Copy link
Contributor Author

whizsid commented Oct 5, 2020

@calebcartwright Thank you for the revision. I changed my PR as you suggested. Can you kindly review it again?

Comment on lines +1664 to +1671
combine_strs_with_missing_comments(
context,
result.trim_end(),
"=",
comment_span,
comment_shape,
true,
)?
Copy link
Member

Choose a reason for hiding this comment

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

We will want to use the comment_shape here for comments, but in cases where there's a where clause we don't want to for the assignment operator and the rhs. That's because in cases where the item has a where clause followed by a block or assignment the block/assignment is not supposed to be indented.

https://github.com/rust-dev-tools/fmt-rfcs/blob/master/guide/items.md#where-clauses

@calebcartwright calebcartwright merged commit 7e31d5d into rust-lang:master Oct 9, 2020
@calebcartwright
Copy link
Member

Thank you!

calebcartwright pushed a commit to calebcartwright/rustfmt that referenced this pull request Nov 29, 2020
* Fixed Comment removed between type name and = issue

* Fixed where clause issue and pass the full span

* has_where condition inline

* Fixed indentation error on where clause

* Removed tmp file
calebcartwright pushed a commit that referenced this pull request Nov 29, 2020
* Fixed Comment removed between type name and = issue

* Fixed where clause issue and pass the full span

* has_where condition inline

* Fixed indentation error on where clause

* Removed tmp file
@karyon
Copy link
Contributor

karyon commented Oct 26, 2021

Backported in #4564

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Comment removed between type name and =
3 participants