You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When rustfmt is run on a block of imports that contains commented-out imports or any other comments, it will delete said comments when collapsing the statements, under a particular condition explained below.
Reproducing
Write a block of imports containing one or more "sub-blocks," such as this:
use std::{
io::{Read,Write},
time::{Duration,Instant},
fmt::Display,
sync::Arc,};
Now comment out all but one list item, ensuring that the remaining item is one of the aforementioned sub-blocks, like so:
use std::{
io::{Read,Write},// time::{Duration, Instant},// fmt::Display,// sync::Arc,};
When formatting, it will collapse to:
use std::io::{Read,Write};
The same is true of normal comments, such as this:
use std::{
io::{Read,Write},// time::{Duration, Instant},// fmt::Display,// sync::Arc,// Hello world!};
Possible Causes
I honestly am not sure what causes this beyond knowing how to reproduce it, as I am not familiar with the internals of rustfmt. Please let me know if you have a good explanation and I will edit this.
The text was updated successfully, but these errors were encountered:
lthoerner
changed the title
rustfmt unexpectedly eats commented-out use statements in block imports
rustfmt unexpectedly eats comments in block imports (use statements)
Aug 3, 2023
Issue
When rustfmt is run on a block of imports that contains commented-out imports or any other comments, it will delete said comments when collapsing the statements, under a particular condition explained below.
Reproducing
Write a block of imports containing one or more "sub-blocks," such as this:
Now comment out all but one list item, ensuring that the remaining item is one of the aforementioned sub-blocks, like so:
When formatting, it will collapse to:
The same is true of normal comments, such as this:
Possible Causes
I honestly am not sure what causes this beyond knowing how to reproduce it, as I am not familiar with the internals of rustfmt. Please let me know if you have a good explanation and I will edit this.
The text was updated successfully, but these errors were encountered: