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).
cc @davidtwco @estebank
Test example (try on playground):
Only
foo::Pub {}in the top levelcorrectshould say "cannot construct ... due to inaccessible fields", the other 3 errors should be "missing field ... in initializer", but it seems like it's treating theenumfield as private (even though it inheritspubfrom theenum).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 possibleenumfields are incapable of giving the right result, if they don't track theenum's own privacy (and they only know they inherit it, whatever it is).cc @davidtwco @estebank