mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-03 04:04:06 +00:00
30 lines
667 B
Rust
30 lines
667 B
Rust
|
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() {}
|