Skip to content

Lint unreachable_pub got easily confused by multiple items in a single pub use ... statement #64762

Closed
@imp

Description

@imp

This code (playground) trips unreachable_pub lint (while being completely legit).

#![deny(unreachable_pub)]

pub use self::m1::{Item1, Item2};

mod m1 {
    pub use self::m2::{Item1, Item2};
    
    mod m2 {
        pub struct Item1;
        pub struct Item2;
    }
}

However, if we break the top-level pub use ... statement into two separate statements (playground) - unreachable_pub lint convinces itself that the code is, indeed, legit.

#![deny(unreachable_pub)]

pub use self::m1::Item1;
pub use self::m1::Item2;

mod m1 {

    pub use self::m2::{Item1, Item2};
    
    mod m2 {
        pub struct Item1;
        pub struct Item2;
    }
}

Metadata

Metadata

Assignees

Labels

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