Skip to content

unreachable_pub false negative when an unreachable type is mentioned in a type alias #116604

Closed
@kpreid

Description

@kpreid

I tried this code:

#![deny(unreachable_pub)]

mod foo {
    pub enum FooError {}
    pub type FooResult<T> = Result<T, FooError>;
}

pub use foo::FooResult;

I expected an unreachable_pub lint because FooError is unreachable. Instead, there is no diagnostic output.

The FooError type is in principle nameable via defining a suitable trait and associated type, but this is probably not the intent of the unreachable_pub lint; the author probably wants to be told to reexport FooError.

Meta

rustc --version --verbose:

rustc 1.73.0 (cc66ad468 2023-10-03)
binary: rustc
commit-hash: cc66ad468955717ab92600c770da8c1601a4ff33
commit-date: 2023-10-03
host: x86_64-apple-darwin
release: 1.73.0
LLVM version: 17.0.2
rustc 1.75.0-nightly (2bbb61989 2023-10-04)
binary: rustc
commit-hash: 2bbb6198933abf193c0ef1d18d9d70f99eed59ba
commit-date: 2023-10-04
host: x86_64-apple-darwin
release: 1.75.0-nightly
LLVM version: 17.0.2

@rustbot label +A-lint +A-visibility

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-visibilityArea: Visibility / privacyC-bugCategory: This is a bug.L-unreachable_pubLint: unreachable_pubT-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