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`

Open
#15,036 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug I-false-positive
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.