Skip to content

Commit 35a4edc

Browse files
committed
Preserve attributes for imports_granularity=Item
Fixes #5030
1 parent c9c1932 commit 35a4edc

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/imports.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ impl UseTree {
608608
span: self.span,
609609
list_item: None,
610610
visibility: self.visibility.clone(),
611-
attrs: None,
611+
attrs: self.attrs.clone(),
612612
});
613613
}
614614
}

tests/source/issue-5030.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// rustfmt-imports_granularity: Item
2+
3+
#[cfg(feature = "foo")]
4+
use std::collections::{
5+
HashMap,
6+
HashSet,
7+
};

tests/target/issue-5030.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// rustfmt-imports_granularity: Item
2+
3+
#[cfg(feature = "foo")]
4+
use std::collections::HashMap;
5+
#[cfg(feature = "foo")]
6+
use std::collections::HashSet;

0 commit comments

Comments
 (0)