fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #66089 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum4560ea788cb

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