`private_bounds` lint does not trigger when associated type is not re-exported
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
pub use self::stuff::Trait1;
mod stuff {
pub trait Trait1 {
type Thing: Trait2;
}
// This triggers it:
// pub(crate) trait Trait2 {}
// This doesn't:
pub trait Trait2 {}
}
Playground link: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=3c1b275b4ccc88b9111b9780ee330916
I expected to see this happen: the private_bounds lint triggers
Instead, this happened: the lint does not trigger - to make it trigger I must mark the second trait pub(crate)
Meta
rustc --version --verbose:
rustc 1.87.0-nightly (f04bbc60f 2025-02-20)
binary: rustc
commit-hash: f04bbc60f8c353ee5ba0677bc583ac4a88b2c180
commit-date: 2025-02-20
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0
<backtrace>
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 with the provided Rust Playground reproduction and trace the compiler's private_bounds lint handling for the associated type bound. Compare the pub(crate) and pub versions, then add or update coverage so the lint triggers when the associated type's bound trait is public but not re-exported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100