-
Notifications
You must be signed in to change notification settings - Fork 933
Closed as not planned
Closed as not planned
Copy link
Labels
Description
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:
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.