]> git.proxmox.com Git - rustc.git/blob - tests/ui/structs/struct-field-cfg.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / structs / struct-field-cfg.rs
1 struct Foo {
2 present: (),
3 }
4
5 fn main() {
6 let foo = Foo { #[cfg(all())] present: () };
7 let _ = Foo { #[cfg(any())] present: () };
8 //~^ ERROR missing field `present` in initializer of `Foo`
9 let _ = Foo { present: (), #[cfg(any())] absent: () };
10 let _ = Foo { present: (), #[cfg(all())] absent: () };
11 //~^ ERROR struct `Foo` has no field named `absent`
12 let Foo { #[cfg(all())] present: () } = foo;
13 let Foo { #[cfg(any())] present: () } = foo;
14 //~^ ERROR pattern does not mention field `present`
15 let Foo { present: (), #[cfg(any())] absent: () } = foo;
16 let Foo { present: (), #[cfg(all())] absent: () } = foo;
17 //~^ ERROR struct `Foo` does not have a field named `absent`
18 }