rust-lang / rust-lang/rust-clippy

clippy::redundant_pub_crate ignores glob export

Open
#7,862 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug I-false-positive I-suggestion-causes-error
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

Lint name:
clippy::redundant_pub_crate

I tried this code:

mod foo {
    pub(crate) struct Bar;
}

pub use foo::*;

I expected to see this happen:
cargo clippy -- -W clippy::redundant_pub_crate should not emit a warning for pub(crate) struct in private module. The pub(crate) visibility prevents Bar from becoming part of the public API. The suggestion to just use pub makes Bar publicly visible outside of the crate.

Instead, this happened: No clippy::redundant_pub_crate warning because pub(crate) is different from just pub for this example.

Meta

Rust version (rustc -Vv):

rustc 1.56.0 (09c42c458 2021-10-18)
binary: rustc
commit-hash: 09c42c45858d5f3aedfa670698275303a3d19afa
commit-date: 2021-10-18
host: x86_64-unknown-linux-gnu
release: 1.56.0
LLVM version: 13.0.0

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 with the implementation and tests for clippy::redundant_pub_crate, then reproduce the provided module and pub use foo::* example with cargo clippy -- -W clippy::redundant_pub_crate. Clarify the expected lint behavior for the glob export and add coverage so the lint and its suggestion match that behavior.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.