Skip to content

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

Closed

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;
    }
}

Activity

  1. changed the title [-]Lint `unreachable_pub` got easily confused by multiple items in single `pub use ...` statement[/-] [+]Lint `unreachable_pub` got easily confused by multiple items in a single `pub use ...` statement[/+] on Sep 25, 2019
  2. added
    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
    A-visibilityArea: Visibility / privacy
    on Sep 25, 2019
  3. added
    C-bugCategory: This is a bug.
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Sep 25, 2019
  4. jhpratt commented on Nov 13, 2019

    @jhpratt
    Member

    Running into this myself. Right now I'm just #[allow]ing it with a link to this issue.

    If someone could lead me in the right direction, I'll give fixing this a shot.

  5. 197g commented on Dec 19, 2019

    @197g
    Contributor

    It also gets confused if the export happens via a glob, also on a single item (Playground).

    #![deny(unreachable_pub)]
    
    mod m1 {
        pub mod m2 {
            pub use super::Item1;
        }
        
        pub struct Item1;
    }
    
    pub use m1::m2::*;
  6. jyn514 commented on Feb 28, 2020

    @jyn514
    Member

    Looks like this is because of #57922 (comment)

  7. lambinoo commented on Jul 11, 2021

    @lambinoo
    Contributor

    @rustbot claim

  8. lambinoo commented on Jul 19, 2021

    @lambinoo
    Contributor

    Since I claimed it 8 days ago, just a follow up.
    I've been able to break the compiler a few times but I'm getting somewhere I think...
    Not to a proper solution tho, just more mess, but that means more knowledge!

    tl;dr: I haven't given up!

  9. petrochenkov commented on Jul 20, 2021

    @petrochenkov
    Contributor

    How to fix this: #82064.

  10. added a commit that references this issue on Jan 10, 2022
  11. lambinoo commented on Jan 10, 2022

    @lambinoo
    Contributor

    Closed by #87487

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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