blob: bc346aea51cfc33748d6cc1d80731ad3ab4754e8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
// aux-build:variants.rs
extern crate variants;
use variants::NonExhaustiveVariants;
fn main() {
let variant_struct = NonExhaustiveVariants::Struct { field: 640 };
//~^ ERROR cannot create non-exhaustive variant
let variant_tuple = NonExhaustiveVariants::Tuple(640);
//~^ ERROR tuple variant `Tuple` is private [E0603]
let variant_unit = NonExhaustiveVariants::Unit;
//~^ ERROR unit variant `Unit` is private [E0603]
match variant_struct {
NonExhaustiveVariants::Unit => "",
//~^ ERROR unit variant `Unit` is private [E0603]
NonExhaustiveVariants::Tuple(fe_tpl) => "",
//~^ ERROR tuple variant `Tuple` is private [E0603]
NonExhaustiveVariants::Struct { field } => ""
//~^ ERROR `..` required with variant marked as non-exhaustive
};
if let NonExhaustiveVariants::Tuple(fe_tpl) = variant_struct {
//~^ ERROR tuple variant `Tuple` is private [E0603]
}
if let NonExhaustiveVariants::Struct { field } = variant_struct {
//~^ ERROR `..` required with variant marked as non-exhaustive
}
}
|