]> git.lizzy.rs Git - rust.git/blob - src/test/ui/struct-literal-variant-in-if.stderr
remove duplicated code and simplify logic
[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 parenthesis
7    |
8 LL |     if x == (E::I { field1: true, field2: 42 }) {}
9    |             ^                                 ^
10
11 error: expected identifier, found keyword `false`
12   --> $DIR/struct-literal-variant-in-if.rs:15:27
13    |
14 LL |     if x == E::V { field: false } {}
15    |                           ^^^^^ expected identifier, found keyword
16 help: you can escape reserved keywords to use them as identifiers
17    |
18 LL |     if x == E::V { field: r#false } {}
19    |                           ^^^^^^^
20
21 error: expected type, found keyword `false`
22   --> $DIR/struct-literal-variant-in-if.rs:15:27
23    |
24 LL |     if x == E::V { field: false } {}
25    |                           ^^^^^ expecting a type here because of type ascription
26    |
27    = note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `<expr>: <type>`
28 note: this expression expects an ascribed type after the colon
29   --> $DIR/struct-literal-variant-in-if.rs:15:20
30    |
31 LL |     if x == E::V { field: false } {}
32    |                    ^^^^^
33    = help: this might be indicative of a syntax error elsewhere
34
35 error: struct literals are not allowed here
36   --> $DIR/struct-literal-variant-in-if.rs:19:13
37    |
38 LL |     if x == E::J { field: -42 } {}
39    |             ^^^^^^^^^^^^^^^^^^^
40 help: surround the struct literal with parenthesis
41    |
42 LL |     if x == (E::J { field: -42 }) {}
43    |             ^                   ^
44
45 error: struct literals are not allowed here
46   --> $DIR/struct-literal-variant-in-if.rs:21:13
47    |
48 LL |     if x == E::K { field: "" } {}
49    |             ^^^^^^^^^^^^^^^^^^
50 help: surround the struct literal with parenthesis
51    |
52 LL |     if x == (E::K { field: "" }) {}
53    |             ^                  ^
54
55 error[E0423]: expected value, found struct variant `E::V`
56   --> $DIR/struct-literal-variant-in-if.rs:10:13
57    |
58 LL |     if x == E::V { field } {}
59    |             ^^^^----------
60    |             |
61    |             help: surround the struct literal with parenthesis: `(E::V { field })`
62
63 error[E0423]: expected value, found struct variant `E::V`
64   --> $DIR/struct-literal-variant-in-if.rs:15:13
65    |
66 LL |     if x == E::V { field: false } {}
67    |             ^^^^-----------------
68    |             |
69    |             help: surround the struct literal with parenthesis: `(E::V { field: false })`
70
71 error[E0308]: mismatched types
72   --> $DIR/struct-literal-variant-in-if.rs:10:20
73    |
74 LL | fn test_E(x: E) {
75    |                 - help: try adding a return type: `-> bool`
76 LL |     let field = true;
77 LL |     if x == E::V { field } {}
78    |                    ^^^^^ expected (), found bool
79    |
80    = note: expected type `()`
81               found type `bool`
82
83 error[E0308]: mismatched types
84   --> $DIR/struct-literal-variant-in-if.rs:23:20
85    |
86 LL |     let y: usize = ();
87    |                    ^^ expected usize, found ()
88    |
89    = note: expected type `usize`
90               found type `()`
91
92 error: aborting due to 9 previous errors
93
94 Some errors occurred: E0308, E0423.
95 For more information about an error, try `rustc --explain E0308`.