-
Notifications
You must be signed in to change notification settings - Fork 926
Rustfmt removes comments in use
s
#3984
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
Comments
Another interesting case: -use b::{
- x,
- y,
-};
-use a::item; // comment
+use a::item;
+use b::{x, y}; // comment
|
I've just found new variant: -use b::{
- x,
- y,
-};
-use a::item /* comment */;
+use a::item;
+use b::{x, y}; Sounds like there are some problems with formatting comments in uses :D |
-use a::item; // really long comment (with `use` exactly 100 characters) ____________________________
+use a::item; /* really long comment (with `use` exactly 100 characters)
+ * ____________________________ */
use b::{x, y}; (is not reproducable with |
@WaffleLapkin - what version of rustfmt are you using, and do you have a rustfmt config file/are you passing any config options via the cli? |
@calebcartwright version:
I don't have rustfmt config nor I pass config options via the cli, except the second example where I have
|
Thanks! I can't reproduce your last example with the latest version of rustfmt on the master branch (which contains a lot of unreleased changes), but the others are still all reproducible |
I worked on this with wise86-android. We noticed that when the We see that the comment transformation is done here: rustfmt/rustfmt-core/rustfmt-lib/src/comment.rs Lines 247 to 254 in 9124dd8
In the case above, Maybe the problem is that the |
@calebcartwright It seems like the case fixed by PR #3999 does not currently work. I was a little surprised by this - given that there's a test case here, but (I would assume) the playground does not lie. The following example (playground link) exhibits the old behavior: -use std::foo::{/* it's a comment! */ bar /* and another */};
+use std::foo::bar;
// filler
-use std::foo::{/* it's a comment! */ bar};
+use std::foo::bar;
// filler
-use std::foo::{bar /* and another */};
+use std::foo::bar; I noticed this occuring with rustfmt 1.4.18-stable, and (per the playground) it seems to still be there in 1.14.21-nightly (2020-09-04 01f2ead). As a side note, it still occurs with just |
@sharnoff - note that the referenced PR was merged to the master branch, so it's included in the unreleased rustfmt v2.0, but not in the released 1.x rustfmt versions you referenced |
@calebcartwright Ah, that makes a bunch of sense! Thanks :) |
This issue is a duplicate of #3720 |
Now that #5853 is merged comments within uses are preserved. As noted, this example #3984 (comment) is a duplicate of another issue, so I'm going to close this now. |
Rustfmt sometimes removes comments in uses with
{}
. For example (diffs fromcargo fmt -- --check
):With
merge_imports = true
:The text was updated successfully, but these errors were encountered: