Skip to content

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

Merged
calebcartwright merged 5 commits into
rust-lang:masterfrom
whizsid:comment_type_alias
Oct 9, 2020
Merged

Fixed 'Comment removed between type name and =' issue#4448
calebcartwright merged 5 commits into
rust-lang:masterfrom
whizsid:comment_type_alias

Conversation

@whizsid

@whizsid whizsid commented Oct 2, 2020

Copy link
Copy Markdown
Contributor

Fixes #4244 .

@calebcartwright calebcartwright left a comment

Copy link
Copy Markdown
Member

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

Comment thread src/formatting/items.rs Outdated
Comment thread src/formatting/items.rs
@whizsid

whizsid commented Oct 5, 2020

Copy link
Copy Markdown
Contributor Author

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

Comment thread src/formatting/items.rs
Comment on lines +1664 to +1671
combine_strs_with_missing_comments(
context,
result.trim_end(),
"=",
comment_span,
comment_shape,
true,
)?

Copy link
Copy Markdown
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

Comment thread tests/target/issue-4244.rs Outdated
Comment thread tmp/test.rs Outdated
@calebcartwright calebcartwright merged commit 7e31d5d into rust-lang:master Oct 9, 2020
@calebcartwright

Copy link
Copy Markdown
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

karyon commented Oct 26, 2021

Copy link
Copy Markdown
Contributor

Backported in #4564

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Comment removed between type name and =

3 participants