-
Notifications
You must be signed in to change notification settings - Fork 996
Closed
Labels
C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICECategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICEE-help-wantedCall for participation: help is requested to fix this issueCall for participation: help is requested to fix this issueonly-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.rsOutput:
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)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICECategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICEE-help-wantedCall for participation: help is requested to fix this issueCall for participation: help is requested to fix this issueonly-with-optionRequires a non-default option value to reproduceRequires a non-default option value to reproduce