Change:
Test example (): Only in the top level 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 field as private (even though it inherits from the ). The "cannot construct ... due to inaccessible fields" error seems to be new in 1.48, as part of , and unmodified since. It's using which seems correct, but it's possible fields are incapable of giving the right result, if they don't track the 's own privacy (and they only know they inherit it, whatever it is). cc
I would also suspect
I ran into this too, but I couldn't make a repro. Thanks eddyb!
P-high: I've run into this a bunch of times and I imagine others have too. It's really annoying and confusing, likely even more so for newcomers!
searched nightlies: from nightly-2020-08-01 to nightly-2020-10-15 regressed nightly: nightly-2020-09-11 searched commits: from to regressed commit: <details<summarybisected with <a href=''cargo-bisect-rustc</av0.6.0</summaryHost triple: x86_64-apple-darwin Reproduce with: </details
Seems very likely that this is due to , as eddyb said. EDIT: Though, as jyn514 suggested, the underlying bug could be , which was then surfaced in .
Update: I've been reading the source code and print-debugging and I think the issue was not introduced in either of those two PRs, but rather that they surfaced a pre-existing issue.
Well, it took a while, but I think I fixed it!
Does this necessitate a 1.48.1 release or shall I wait for 1.49?
it will be in 1.50 unless backported:
Ok. Thank you for the quick reply.

Discussion:
Ok(ty::Visibility::Restricted(DefId::local(CRATE_DEF_INDEX))) } ast::VisibilityKind::Inherited => { <del> Ok(ty::Visibility::Restricted(parent_scope.module.normal_ancestor_id)) </del> <ins> if matches!(self.parent_scope.module.kind, ModuleKind::Def(DefKind::Enum, _, _)) { // Any inherited visibility resolved directly inside an enum // (e.g. variants or fields) inherits from the visibility of the enum. let parent_enum = self.parent_scope.module.def_id().unwrap().expect_local(); Ok(self.r.visibilities[&parent_enum]) } else { // If it's not in an enum, its visibility is restricted to the `mod` item // that it's defined in. Ok(ty::Visibility::Restricted(self.parent_scope.module.normal_ancestor_id)) } </ins> } ast::VisibilityKind::Restricted { ref path, id, .. } => { // For visibilities we are not ready to provide correct implementation of "uniform

}, } <ins> #[derive(Debug)] </ins> enum ModuleKind { /// An anonymous module; e.g., just a block. ///

if no_accessible_remaining_fields { self.report_no_accessible_fields(adt_ty, span); } else { <del> self.report_missing_field(adt_ty, span, remaining_fields); </del> <ins> self.report_missing_fields(adt_ty, span, remaining_fields); </ins> } }

/// /// error: aborting due to previous error /// ``` <del> fn report_missing_field( </del> <ins> fn report_missing_fields( </ins> &self, adt_ty: Ty<'tcx>, span: Span,

<ins> mod foo { pub struct Pub { private: () } pub enum Enum { Variant { x: (), y: () }, Other } fn correct() { Pub {}; //~^ ERROR missing field `private` in initializer of `Pub` Enum::Variant { x: () }; //~^ ERROR missing field `y` in initializer of `Enum` } } fn correct() { foo::Pub {}; //~^ ERROR cannot construct `Pub` with struct literal syntax due to inaccessible fields } fn wrong() { foo::Enum::Variant { x: () }; //~^ ERROR missing field `y` in initializer of `Enum` foo::Enum::Variant { }; //~^ ERROR missing fields `x`, `y` in initializer of `Enum` } fn main() {} </ins>

<ins> error[E0063]: missing field `private` in initializer of `Pub` --> $DIR/issue-79593.rs:10:9 | LL |         Pub {}; |         ^^^ missing `private` error[E0063]: missing field `y` in initializer of `Enum` --> $DIR/issue-79593.rs:12:9 | LL |         Enum::Variant { x: () }; |         ^^^^^^^^^^^^^ missing `y` error: cannot construct `Pub` with struct literal syntax due to inaccessible fields --> $DIR/issue-79593.rs:18:5 | LL |     foo::Pub {}; |     ^^^^^^^^ error[E0063]: missing field `y` in initializer of `Enum` --> $DIR/issue-79593.rs:23:5 | LL |     foo::Enum::Variant { x: () }; |     ^^^^^^^^^^^^^^^^^^ missing `y` error[E0063]: missing fields `x`, `y` in initializer of `Enum` --> $DIR/issue-79593.rs:25:5 | LL |     foo::Enum::Variant { }; |     ^^^^^^^^^^^^^^^^^^ missing `x`, `y` error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0063`. </ins>