2017-11-03 14:15:15 -05:00
|
|
|
// aux-build:variants.rs
|
2019-03-22 11:19:12 -05:00
|
|
|
|
2017-11-03 14:15:15 -05:00
|
|
|
extern crate variants;
|
|
|
|
|
|
|
|
use variants::NonExhaustiveVariants;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let variant_struct = NonExhaustiveVariants::Struct { field: 640 };
|
|
|
|
//~^ ERROR cannot create non-exhaustive variant
|
|
|
|
|
2019-03-22 11:19:12 -05:00
|
|
|
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]
|
2017-11-03 14:15:15 -05:00
|
|
|
|
|
|
|
match variant_struct {
|
|
|
|
NonExhaustiveVariants::Unit => "",
|
2019-03-22 11:19:12 -05:00
|
|
|
//~^ ERROR unit variant `Unit` is private [E0603]
|
2017-11-03 14:15:15 -05:00
|
|
|
NonExhaustiveVariants::Tuple(fe_tpl) => "",
|
2019-03-22 11:19:12 -05:00
|
|
|
//~^ ERROR tuple variant `Tuple` is private [E0603]
|
2017-11-03 14:15:15 -05:00
|
|
|
NonExhaustiveVariants::Struct { field } => ""
|
|
|
|
//~^ ERROR `..` required with variant marked as non-exhaustive
|
|
|
|
};
|
2019-03-22 11:19:12 -05:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
2017-11-03 14:15:15 -05:00
|
|
|
}
|