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