rust-lang / rust-lang/rust-clippy
`wildcard_imports` should allow filesystem-structural wildcard re-exports even for `pub(crate) use` as it already allows for `pub use`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
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.
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.
Research direction
Start by locating the wildcard_exports lint implementation and its tests, then compare how pub use and pub(crate) use are handled. Done means the filesystem-structural pub(crate) use foo::* pattern is accepted consistently with the public re-export example, with relevant tests passing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100