]> git.lizzy.rs Git - rust.git/blob - src/test/ui/struct-literal-variant-in-if.stderr
Rollup merge of #61084 - blkerby:unreachable_doc, r=KodrAus
[rust.git] / src / test / ui / struct-literal-variant-in-if.stderr
1 error: struct literals are not allowed here
2   --> $DIR/struct-literal-variant-in-if.rs:13:13
3    |
4 LL |     if x == E::I { field1: true, field2: 42 } {}
5    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6 help: surround the struct literal with parentheses
7    |
8 LL |     if x == (E::I { field1: true, field2: 42 }) {}
9    |             ^                                 ^
10
11 error: struct literals are not allowed here
12   --> $DIR/struct-literal-variant-in-if.rs:15:13
13    |
14 LL |     if x == E::V { field: false } {}
15    |             ^^^^^^^^^^^^^^^^^^^^^
16 help: surround the struct literal with parentheses
17    |
18 LL |     if x == (E::V { field: false }) {}
19    |             ^                     ^
20
21 error: struct literals are not allowed here
22   --> $DIR/struct-literal-variant-in-if.rs:17:13
23    |
24 LL |     if x == E::J { field: -42 } {}
25    |             ^^^^^^^^^^^^^^^^^^^
26 help: surround the struct literal with parentheses
27    |
28 LL |     if x == (E::J { field: -42 }) {}
29    |             ^                   ^
30
31 error: struct literals are not allowed here
32   --> $DIR/struct-literal-variant-in-if.rs:19:13
33    |
34 LL |     if x == E::K { field: "" } {}
35    |             ^^^^^^^^^^^^^^^^^^
36 help: surround the struct literal with parentheses
37    |
38 LL |     if x == (E::K { field: "" }) {}
39    |             ^                  ^
40
41 error[E0423]: expected value, found struct variant `E::V`
42   --> $DIR/struct-literal-variant-in-if.rs:10:13
43    |
44 LL |     if x == E::V { field } {}
45    |             ^^^^----------
46    |             |
47    |             help: surround the struct literal with parenthesis: `(E::V { field })`
48
49 error[E0308]: mismatched types
50   --> $DIR/struct-literal-variant-in-if.rs:10:20
51    |
52 LL | fn test_E(x: E) {
53    |                 - help: try adding a return type: `-> bool`
54 LL |     let field = true;
55 LL |     if x == E::V { field } {}
56    |                    ^^^^^ expected (), found bool
57    |
58    = note: expected type `()`
59               found type `bool`
60
61 error[E0308]: mismatched types
62   --> $DIR/struct-literal-variant-in-if.rs:21:20
63    |
64 LL |     let y: usize = ();
65    |                    ^^ expected usize, found ()
66    |
67    = note: expected type `usize`
68               found type `()`
69
70 error: aborting due to 7 previous errors
71
72 Some errors have detailed explanations: E0308, E0423.
73 For more information about an error, try `rustc --explain E0308`.