rust-lang / rust-lang/rust

private_bounds: false negative on trait impl

Open
#139,159 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-lints C-bug L-false-negative L-private_bounds T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
#![allow(unused)]
struct Type<T>(T);
trait PubTrait {}
mod a {
    trait PrivTrait {}
    impl<T: PrivTrait> super::PubTrait for super::Type<T> {}
}
Current output
None
Desired output
private_bounds warning
Rationale and extra context

The T: PrivTrait bound is more private than both PubTrait and Type, so that should give a warning.

Other cases

Rust Version
rustc 1.88.0-nightly (1799887bb 2025-03-29)
binary: rustc
commit-hash: 1799887bb281d1ab49287750f1950b8c738c6b77
commit-date: 2025-03-29
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.1
Anything else?

No response

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

Reproduce the provided Rust snippet with rustc 1.88.0-nightly and compare the current output with the requested private_bounds warning. Start by tracing how private bounds are evaluated for trait implementations; done means the T: PrivTrait bound produces a warning in this case without regressing the other visibility checks.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.