Skip to content

Conversation

@dingxiangfei2009
Copy link

@dingxiangfei2009 dingxiangfei2009 commented Nov 10, 2025

Fix #6666

Related to #4991

This patch fixes the issue that import_granularity does not apply import_granuarity to uses behind attributes known to the compiler that the out coding style applies transparently. Attributes like #[cfg], #[cfg_attr], #[warn], #[deny], #[allow].

We achieve this by temporarily swap out the default use tree and merge sub-items in a temporary use tree. This tree is then later merged back into the default use tree, with the original attributes grandfathered.

Fix rust-lang#6666

We would like to allow formatting items with attributes that
conceptually allows outer styling as well.

Signed-off-by: Xiangfei Ding <dingxiangfei2009@protonmail.ch>
@dingxiangfei2009 dingxiangfei2009 changed the title Allow formatting of use behind #[cfg*] import_granularity: Allow formatting of use behind #[cfg*] Nov 20, 2025
@dingxiangfei2009 dingxiangfei2009 changed the title import_granularity: Allow formatting of use behind #[cfg*] [import_granularity] Allow formatting of use behind #[cfg*] Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

imports_granularity is not respected for #[cfg]'d items

2 participants