]> git.lizzy.rs Git - rust.git/blob - tests/ui/parser/struct-literal-variant-in-if.rs
Auto merge of #107688 - lukas-code:projection-with-lifetime, r=jackh726
[rust.git] / tests / ui / parser / struct-literal-variant-in-if.rs
1 #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
2 enum E {
3     V { field: bool },
4     I { field1: bool, field2: usize },
5     J { field: isize },
6     K { field: &'static str},
7 }
8 fn test_E(x: E) {
9     let field = true;
10     if x == E::V { field } {}
11     //~^ ERROR expected value, found struct variant `E::V`
12     //~| ERROR mismatched types
13     if x == E::I { field1: true, field2: 42 } {}
14     //~^ ERROR struct literals are not allowed here
15     if x == E::V { field: false } {}
16     //~^ ERROR struct literals are not allowed here
17     if x == E::J { field: -42 } {}
18     //~^ ERROR struct literals are not allowed here
19     if x == E::K { field: "" } {}
20     //~^ ERROR struct literals are not allowed here
21     let y: usize = ();
22     //~^ ERROR mismatched types
23 }
24
25 fn main() {}