Closed
Description
Test example (try on playground):
mod foo {
pub struct Pub { private: () }
pub enum Enum {
Variant { x: (), y: () },
Other
}
fn correct() {
Pub {};
Enum::Variant { x: () };
}
}
fn correct() {
foo::Pub {};
}
fn wrong() {
foo::Enum::Variant { x: () };
}
Only foo::Pub {}
in the top level correct
should say "cannot construct ... due to inaccessible fields", the other 3 errors should be "missing field ... in initializer", but it seems like it's treating the enum
field as private (even though it inherits pub
from the enum
).
The "cannot construct ... due to inaccessible fields" error seems to be new in 1.48, as part of #76524, and unmodified since.
It's using field.vis.is_accessible_from(...)
which seems correct, but it's possible enum
fields are incapable of giving the right result, if they don't track the enum
's own privacy (and they only know they inherit it, whatever it is).
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Visibility / privacyCategory: This is a bug.Diagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: Confusing error or lint; hard to understand for new users.High priorityRelevant to the compiler team, which will review and decide on the PR/issue.Performance or correctness regression from one stable version to another.