Skip to content

private_bounds lint does not trigger when associated type is not re-exported #137438

Open
@paolobarbolini

Description

@paolobarbolini

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.L-private_boundsLint: private_boundsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions