Closed
Description
openedon Oct 16, 2021
If I format this file
#[cfg(feature = "foo")]
use std::collections::{
HashMap,
HashSet,
};
fn main() {
println!("Hello, world!");
}
with rustfmt --config imports_granularity=Item
, rustfmt
removes the cfg
attribute:
$ rustfmt --config imports_granularity=Item main.rs
Output:
use std::collections::HashMap;
use std::collections::HashSet;
fn main() {
println!("Hello, world!");
}
This only happens if there is more than one import in the use
statement, i. e. formatting
#[cfg(feature = "foo")]
use std::collections::{
HashMap,
};
correctly retains the attribute.
rustfmt
was installed via rustup
, current nightly:
$ rustfmt --version
rustfmt 1.4.37-nightly (c102653 2021-10-15)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment