From acdab00ecc4c5064b6a42f87a523961304678c06 Mon Sep 17 00:00:00 2001 From: Tom Milligan Date: Sat, 16 Apr 2022 12:12:27 +0100 Subject: [PATCH] [review] check interaction with import grouping --- tests/source/issue-5030.rs | 15 +++++++++++++++ tests/target/issue-5030.rs | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/tests/source/issue-5030.rs b/tests/source/issue-5030.rs index f367e79f01f..08ffaac7d1d 100644 --- a/tests/source/issue-5030.rs +++ b/tests/source/issue-5030.rs @@ -1,7 +1,22 @@ // rustfmt-imports_granularity: Item +// rustfmt-group_imports: One +// Confirm that attributes are duplicated to all items in the use statement #[cfg(feature = "foo")] use std::collections::{ HashMap, HashSet, }; + +// Separate the imports below from the ones above +const A: usize = 0; + +// Copying attrs works with import grouping as well +#[cfg(feature = "foo")] +use std::collections::{ + HashMap, + HashSet, +}; + +#[cfg(feature = "spam")] +use qux::{bar, baz}; diff --git a/tests/target/issue-5030.rs b/tests/target/issue-5030.rs index b371331ed00..8ac3888bdbe 100644 --- a/tests/target/issue-5030.rs +++ b/tests/target/issue-5030.rs @@ -1,5 +1,20 @@ // rustfmt-imports_granularity: Item +// rustfmt-group_imports: One +// Confirm that attributes are duplicated to all items in the use statement +#[cfg(feature = "foo")] +use std::collections::HashMap; +#[cfg(feature = "foo")] +use std::collections::HashSet; + +// Separate the imports below from the ones above +const A: usize = 0; + +// Copying attrs works with import grouping as well +#[cfg(feature = "spam")] +use qux::bar; +#[cfg(feature = "spam")] +use qux::baz; #[cfg(feature = "foo")] use std::collections::HashMap; #[cfg(feature = "foo")]