2019-04-18 11:35:11 -07:00
|
|
|
error: struct literals are not allowed here
|
|
|
|
--> $DIR/struct-literal-variant-in-if.rs:13:13
|
|
|
|
|
|
|
|
|
LL | if x == E::I { field1: true, field2: 42 } {}
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
help: surround the struct literal with parenthesis
|
|
|
|
|
|
|
|
|
LL | if x == (E::I { field1: true, field2: 42 }) {}
|
|
|
|
| ^ ^
|
|
|
|
|
|
|
|
error: expected identifier, found keyword `false`
|
|
|
|
--> $DIR/struct-literal-variant-in-if.rs:15:27
|
|
|
|
|
|
|
|
|
LL | if x == E::V { field: false } {}
|
|
|
|
| ^^^^^ expected identifier, found keyword
|
|
|
|
help: you can escape reserved keywords to use them as identifiers
|
|
|
|
|
|
|
|
|
LL | if x == E::V { field: r#false } {}
|
|
|
|
| ^^^^^^^
|
|
|
|
|
|
|
|
error: expected type, found keyword `false`
|
|
|
|
--> $DIR/struct-literal-variant-in-if.rs:15:27
|
|
|
|
|
|
|
|
|
LL | if x == E::V { field: false } {}
|
|
|
|
| ^^^^^ expecting a type here because of type ascription
|
|
|
|
|
|
|
|
|
= note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `<expr>: <type>`
|
|
|
|
note: this expression expects an ascribed type after the colon
|
|
|
|
--> $DIR/struct-literal-variant-in-if.rs:15:20
|
|
|
|
|
|
|
|
|
LL | if x == E::V { field: false } {}
|
|
|
|
| ^^^^^
|
|
|
|
= help: this might be indicative of a syntax error elsewhere
|
|
|
|
|
|
|
|
error: struct literals are not allowed here
|
|
|
|
--> $DIR/struct-literal-variant-in-if.rs:19:13
|
|
|
|
|
|
|
|
|
LL | if x == E::J { field: -42 } {}
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^
|
|
|
|
help: surround the struct literal with parenthesis
|
|
|
|
|
|
|
|
|
LL | if x == (E::J { field: -42 }) {}
|
|
|
|
| ^ ^
|
|
|
|
|
|
|
|
error: struct literals are not allowed here
|
|
|
|
--> $DIR/struct-literal-variant-in-if.rs:21:13
|
|
|
|
|
|
|
|
|
LL | if x == E::K { field: "" } {}
|
|
|
|
| ^^^^^^^^^^^^^^^^^^
|
|
|
|
help: surround the struct literal with parenthesis
|
|
|
|
|
|
|
|
|
LL | if x == (E::K { field: "" }) {}
|
|
|
|
| ^ ^
|
|
|
|
|
2019-04-15 08:08:46 -07:00
|
|
|
error[E0423]: expected value, found struct variant `E::V`
|
2019-04-18 11:35:11 -07:00
|
|
|
--> $DIR/struct-literal-variant-in-if.rs:10:13
|
2019-04-15 08:08:46 -07:00
|
|
|
|
|
|
|
|
LL | if x == E::V { field } {}
|
|
|
|
| ^^^^----------
|
|
|
|
| |
|
|
|
|
| help: surround the struct literal with parenthesis: `(E::V { field })`
|
|
|
|
|
2019-04-18 11:35:11 -07:00
|
|
|
error[E0423]: expected value, found struct variant `E::V`
|
|
|
|
--> $DIR/struct-literal-variant-in-if.rs:15:13
|
|
|
|
|
|
|
|
|
LL | if x == E::V { field: false } {}
|
|
|
|
| ^^^^-----------------
|
|
|
|
| |
|
|
|
|
| help: surround the struct literal with parenthesis: `(E::V { field: false })`
|
|
|
|
|
2019-04-15 08:08:46 -07:00
|
|
|
error[E0308]: mismatched types
|
2019-04-18 11:35:11 -07:00
|
|
|
--> $DIR/struct-literal-variant-in-if.rs:10:20
|
2019-04-15 08:08:46 -07:00
|
|
|
|
|
|
|
|
LL | fn test_E(x: E) {
|
|
|
|
| - help: try adding a return type: `-> bool`
|
|
|
|
LL | let field = true;
|
|
|
|
LL | if x == E::V { field } {}
|
|
|
|
| ^^^^^ expected (), found bool
|
|
|
|
|
|
|
|
|
= note: expected type `()`
|
|
|
|
found type `bool`
|
|
|
|
|
|
|
|
error[E0308]: mismatched types
|
2019-04-18 11:35:11 -07:00
|
|
|
--> $DIR/struct-literal-variant-in-if.rs:23:20
|
2019-04-15 08:08:46 -07:00
|
|
|
|
|
|
|
|
LL | let y: usize = ();
|
|
|
|
| ^^ expected usize, found ()
|
|
|
|
|
|
|
|
|
= note: expected type `usize`
|
|
|
|
found type `()`
|
|
|
|
|
2019-04-18 11:35:11 -07:00
|
|
|
error: aborting due to 9 previous errors
|
2019-04-15 08:08:46 -07:00
|
|
|
|
|
|
|
Some errors occurred: E0308, E0423.
|
|
|
|
For more information about an error, try `rustc --explain E0308`.
|