`imports_granularity` is not respected for `#[cfg]`'d items
Open
@dingxiangfei2009 is already working on this.
Since Jun 16, 2026.
A-cfg
A-imports
C-bug
I-changes-semantics
UO-imports_granularity
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Example with imports_granularity = "crate". The following:
#[cfg(true)]
use std::{cmp::Ordering, hash::Hash, hash::Hasher};
use core::{cmp::Ordering, hash::Hash, hash::Hasher};
will normalise to:
#[cfg(true)]
use std::{cmp::Ordering, hash::Hash, hash::Hasher};
use core::{cmp::Ordering, hash::{Hash, Hasher}};
Note that the desire to avoid messing with cfgs is too conservative here: the imports are not grouped in the same way.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.