rust-clippy icon indicating copy to clipboard operation
rust-clippy copied to clipboard

`wildcard_imports` should allow filesystem-structural wildcard re-exports even for `pub(crate) use` as it already allows for `pub use`

Open sandersaares opened this issue 4 months ago • 0 comments

It is valuable to organize code in different files without necessarily representing that hierarchy in the module tree, by re-exporting types up toward the root:

mod foo;

pub use foo::*;

Here, we publicly expose T from foo.rs not as crate::foo::T but as crate::T - the module is merely to better organize code, not as something meant to express public API module structure.

That works fine and is allowed by clippy::wildcard_exports in its default configuration.

This technique is also valuable for non-public types:

mod foo;

pub(crate) use foo::*;

Unfortunately, clippy::wildcard_exports is not happy about this one. I believe it should be happy about it - this is just another form of the same pattern and whether it says pub or pub(crate) should not make any difference.

sandersaares avatar Jun 12 '25 05:06 sandersaares