group_imports reorders use
statements arounds comments, changing their meaning
#6241
Labels
use
statements arounds comments, changing their meaning
#6241
This is similar to #3720, but for group_imports settings such as
StdExternalCrate
. rust-lang/rust#126776 shows the consequences of that: it is now impossible to have a "chunk" ofuse
statements that have a comment above them. rustfmt will happily reorder them and keep the comment attached to the immediateuse
item after it, therefore fundamentally changing its meaning. That's extremely frustrating -- having the tool make it essentially impossible to have comments that clarify the intent of my code.In situations like this:
rustfmt should view the comment as "breaking apart" the
use
block into multiple blocks, similar to what it does if there was something else, like amod
, in place of the comment.group_imports
should then be applied to both groups separately. That would avoid such semantics-altering reformatting.The text was updated successfully, but these errors were encountered: