Closed
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 errors
rustc 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 implied
rustc 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
Area: Messages for errors, warnings, and lintsArea: Visibility / privacyDiagnostics: A diagnostic that is giving misleading or incorrect information.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.Relevant to the compiler team, which will review and decide on the PR/issue.