- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-visibilityArea: Visibility / privacyArea: Visibility / privacyD-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
See https://godbolt.org/z/8bWh445hh
Given
enum Foo {
  pub(crate) Bar,
  Baz {
    pub(crate) x: i32,
  },
}I get
error[E0449]: unnecessary visibility qualifier
 --> <source>:2:3
  |
2 |   pub(crate) Bar,
  |   ^^^^^^^^^^
error[E0449]: unnecessary visibility qualifier
 --> <source>:4:5
  |
4 |     pub(crate) x: i32,
  |     ^^^^^^^^^^
error: aborting due to 2 previous errorsrustc correctly describes these as "unnecessary" when they are a plain pub:
error[E0449]: unnecessary visibility qualifier
 --> <source>:2:3
  |
2 |   pub Bar,
  |   ^^^ `pub` not permitted here because it's impliedrustc should instead state that non-pub visibility qualifiers are not permitted, rather than being unnecessary. I suggest a diagnostic like
error[E0449]: visibility qualifiers are not permitted inside of enums
 --> <source>:2:3
  |
2 |   pub(crate) Bar,
  |   ^^^^^^^^^^ (There is a similar diagnostic bug around putting pub(crate) or pub(self) on trait items.)
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-visibilityArea: Visibility / privacyArea: Visibility / privacyD-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.