2019-04-15 15:08:46 +00:00
|
|
|
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
|
|
|
|
enum E {
|
2019-04-18 18:35:11 +00:00
|
|
|
V { field: bool },
|
|
|
|
I { field1: bool, field2: usize },
|
|
|
|
J { field: isize },
|
|
|
|
K { field: &'static str},
|
2019-04-15 15:08:46 +00:00
|
|
|
}
|
|
|
|
fn test_E(x: E) {
|
|
|
|
let field = true;
|
|
|
|
if x == E::V { field } {}
|
|
|
|
//~^ ERROR expected value, found struct variant `E::V`
|
|
|
|
//~| ERROR mismatched types
|
2019-04-18 18:35:11 +00:00
|
|
|
if x == E::I { field1: true, field2: 42 } {}
|
|
|
|
//~^ ERROR struct literals are not allowed here
|
|
|
|
if x == E::V { field: false } {}
|
2019-04-18 20:58:57 +00:00
|
|
|
//~^ ERROR struct literals are not allowed here
|
2019-04-18 18:35:11 +00:00
|
|
|
if x == E::J { field: -42 } {}
|
|
|
|
//~^ ERROR struct literals are not allowed here
|
|
|
|
if x == E::K { field: "" } {}
|
|
|
|
//~^ ERROR struct literals are not allowed here
|
2019-04-15 15:08:46 +00:00
|
|
|
let y: usize = ();
|
|
|
|
//~^ ERROR mismatched types
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|