Skip to content

private_interfaces reports the visability of items in pseudocode #131220

Closed
@lolbinarycat

Description

@lolbinarycat

Code

#![allow(dead_code)]

mod a {
    pub mod b {
        pub(in crate::a) struct Huh;
        pub fn eee() -> Huh { Huh }
    }
}

Current output


warning: type `Huh` is more private than the item `eee`
 --> src/lib.rs:6:9
  |
6 |         pub fn eee() -> Huh { Huh }
  |         ^^^^^^^^^^^^^^^^^^^ function `eee` is reachable at visibility `pub(crate)`
  |
note: but type `Huh` is only usable at visibility `pub(a)`
 --> src/lib.rs:5:9
  |
5 |         pub(in crate::a) struct Huh;
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  = note: `#[warn(private_interfaces)]` on by default

Desired output


warning: type `Huh` is more private than the item `eee`
 --> src/lib.rs:6:9
  |
6 |         pub fn eee() -> Huh { Huh }
  |         ^^^^^^^^^^^^^^^^^^^ function `eee` is reachable at visibility `pub(crate)`
  |
note: but type `Huh` is only usable at visibility `pub(in crate::a)`
 --> src/lib.rs:5:9
  |
5 |         pub(in crate::a) struct Huh;
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  = note: `#[warn(private_interfaces)]` on by default

Rationale and extra context

pub(a) is not valid rust code in any edition.

Other cases

No response

Rust Version

rustc 1.83.0-nightly (2bd1e89 2024-09-26)
binary: rustc
commit-hash: 2bd1e89
commit-date: 2024-09-26
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.0

Anything else?

No response

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsD-papercutDiagnostics: An error or lint that needs small tweaks.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