Add a test for single variant matches

This commit is contained in:
Oliver Scherer 2018-11-26 10:26:54 +01:00
parent d8ece188b8
commit 866664c8bb
2 changed files with 23 additions and 2 deletions

View file

@ -2,6 +2,14 @@ enum Foo {
Prob,
}
const FOO: u32 = match Foo::Prob {
Foo::Prob => 42, //~ ERROR unimplemented expression type
};
const BAR: u32 = match Foo::Prob {
x => 42, //~ ERROR unimplemented expression type
};
impl Foo {
pub const fn as_val(&self) -> u8 {
use self::Foo::*;

View file

@ -1,8 +1,21 @@
error[E0019]: constant contains unimplemented expression type
--> $DIR/single_variant_match_ice.rs:6:5
|
LL | Foo::Prob => 42, //~ ERROR unimplemented expression type
| ^^^^^^^^^
error[E0019]: constant contains unimplemented expression type
--> $DIR/single_variant_match_ice.rs:10:5
|
LL | x => 42, //~ ERROR unimplemented expression type
| ^
error: `if`, `match`, `&&` and `||` are not stable in const fn
--> $DIR/single_variant_match_ice.rs:10:13
--> $DIR/single_variant_match_ice.rs:18:13
|
LL | Prob => 0x1, //~ ERROR `if`, `match`, `&&` and `||` are not stable in const fn
| ^^^^
error: aborting due to previous error
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0019`.