Skip to content

Suggestion for pub(crate) doesn't handle reexports well #57410

Closed
@alexcrichton

Description

@alexcrichton

First reported upstream this code:

#![warn(unreachable_pub)]

pub use self::m::f;

mod m {
    pub use self::imp::f;  // Recommends pub(crate), but that causes an error above.
    mod imp {
        pub fn f() {}
    }
}

gives the warning:

warning: unreachable `pub` item
 --> src/lib.rs:6:5
  |
6 |     pub use self::imp::f;  // Recommends pub(crate), but that causes an error above.
  |     ---^^^^^^^^^^^^^^^^^^
  |     |
  |     help: consider restricting its visibility: `pub(crate)`
  |
note: lint level defined here
 --> src/lib.rs:1:9
  |
1 | #![warn(unreachable_pub)]
  |         ^^^^^^^^^^^^^^^
  = help: or consider exporting it for use by other crates

    Finished dev [unoptimized + debuginfo] target(s) in 0.57s

but the suggestions, when applied, doesn't compile!

Metadata

Metadata

Assignees

Labels

A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions