-
Notifications
You must be signed in to change notification settings - Fork 883
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
Comment removed between type name and = #4244
Comments
For anyone interested in working on this, here are some of the relevant sections of the code: rustfmt/src/formatting/items.rs Lines 1591 to 1599 in 2927e89
The dropping of the comment happens here on this line when the current formatting result is mashed together with the assignment operator. The individual elements of the item (the visibility, ident, generics, generic bounds, etc.) are formatted independently and then combined, but the comment is dropped because there's no checking for comments within the spans between. In this particular case that happens to be the span between the item's ident and the assignment operator, though more generally this would be the span between the assignment operator on the hi and the lo would be the end of the rightmost item element present rustfmt/src/formatting/items.rs Line 1650 in 2927e89
Note that the full span of the item can be found in the corresponding match arm in visitor.rs, which is needed for finding this between span before the assignment operator rustfmt/src/formatting/visitor.rs Lines 599 to 611 in 2927e89
|
This is one where I think a comment is justified; today we do not enforce such bounds (i.e. the compiler does not check that the right-hand side of a
type
definition actually conforms to such a bound), and the compiler actually errors if you try to include it (because we don't want people to mistakenly think that such bounds are enforced).But the comment here serves a useful purpose (about the intent, that we intend for this type definition to conform to the bound).
Originally posted by @pnkfelix in #2781 (comment)
The text was updated successfully, but these errors were encountered: