-
Notifications
You must be signed in to change notification settings - Fork 933
Closed
Labels
bugPanic, non-idempotency, invalid code, etc.Panic, non-idempotency, invalid code, etc.help wantedonly-with-optionrequires a non-default option value to reproducerequires a non-default option value to reproduce
Description
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)
Metadata
Metadata
Assignees
Labels
bugPanic, non-idempotency, invalid code, etc.Panic, non-idempotency, invalid code, etc.help wantedonly-with-optionrequires a non-default option value to reproducerequires a non-default option value to reproduce