Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid unreachable_pub suggestion for enum with fields #103317

Closed
l4l opened this issue Oct 20, 2022 · 0 comments · Fixed by #103338
Closed

Invalid unreachable_pub suggestion for enum with fields #103317

l4l opened this issue Oct 20, 2022 · 0 comments · Fixed by #103338
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@l4l
Copy link
Contributor

l4l commented Oct 20, 2022

Given the following code:

#[warn(unreachable_pub)]
mod inner {
    #[allow(unused)]
    pub enum T {
        A(u32),
    }
}

The current output is:

warning: unreachable `pub` item
 --> src/main.rs:4:5
  |
4 |     pub enum T {
  |     ---^^^^^^^
  |     |
  |     help: consider restricting its visibility: `pub(crate)`
  |
note: the lint level is defined here
 --> src/main.rs:1:8
  |
1 | #[warn(unreachable_pub)]
  |        ^^^^^^^^^^^^^^^
  = help: or consider exporting it for use by other crates

warning: unreachable `pub` field
 --> src/main.rs:5:11
  |
5 |         A(u32),
  |           -^^
  |           |
  |           help: consider restricting its visibility: `pub(crate)`

Which basically brokes cargo-fix, i.e cargo fix --broken-code produces invalid code:

#[warn(unreachable_pub)]
mod inner {
    #[allow(unused)]
    pub(crate) enum T {
        A(pub(crate)u32),
    }
}

That seems to affect any enum with variant fields.

@l4l l4l added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 20, 2022
@bors bors closed this as completed in 5ee0fb1 Oct 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant