Skip to content

Commit 866664c

Browse files
committed
Add a test for single variant matches
1 parent d8ece18 commit 866664c

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/test/ui/consts/single_variant_match_ice.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ enum Foo {
22
Prob,
33
}
44

5+
const FOO: u32 = match Foo::Prob {
6+
Foo::Prob => 42, //~ ERROR unimplemented expression type
7+
};
8+
9+
const BAR: u32 = match Foo::Prob {
10+
x => 42, //~ ERROR unimplemented expression type
11+
};
12+
513
impl Foo {
614
pub const fn as_val(&self) -> u8 {
715
use self::Foo::*;
Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1+
error[E0019]: constant contains unimplemented expression type
2+
--> $DIR/single_variant_match_ice.rs:6:5
3+
|
4+
LL | Foo::Prob => 42, //~ ERROR unimplemented expression type
5+
| ^^^^^^^^^
6+
7+
error[E0019]: constant contains unimplemented expression type
8+
--> $DIR/single_variant_match_ice.rs:10:5
9+
|
10+
LL | x => 42, //~ ERROR unimplemented expression type
11+
| ^
12+
113
error: `if`, `match`, `&&` and `||` are not stable in const fn
2-
--> $DIR/single_variant_match_ice.rs:10:13
14+
--> $DIR/single_variant_match_ice.rs:18:13
315
|
416
LL | Prob => 0x1, //~ ERROR `if`, `match`, `&&` and `||` are not stable in const fn
517
| ^^^^
618

7-
error: aborting due to previous error
19+
error: aborting due to 3 previous errors
820

21+
For more information about this error, try `rustc --explain E0019`.

0 commit comments

Comments
 (0)