rust/src/test/ui/issues/issue-76077-1.fixed
David Wood 409c141973
typeck/pat: inaccessible private fields
This commit adjusts the missing field diagnostic logic for struct
patterns in typeck to improve the diagnostic when the missing fields are
inaccessible.

Signed-off-by: David Wood <david@davidtw.co>
2020-09-10 18:52:00 +01:00

19 lines
464 B
Rust

// run-rustfix
#![allow(dead_code, unused_variables)]
pub mod foo {
#[derive(Default)]
pub struct Foo { invisible: bool, }
#[derive(Default)]
pub struct Bar { pub visible: bool, invisible: bool, }
}
fn main() {
let foo::Foo { .. } = foo::Foo::default();
//~^ ERROR pattern requires `..` due to inaccessible fields
let foo::Bar { visible, .. } = foo::Bar::default();
//~^ ERROR pattern requires `..` due to inaccessible fields
}