We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 285a585 commit cef249fCopy full SHA for cef249f
tests/run-pass/enums.rs
@@ -23,6 +23,28 @@ fn test(me: MyEnum) {
23
}
24
25
26
+fn discriminant_overflow() {
27
+ // Tests for https://github.com/rust-lang/rust/issues/62138.
28
+ #[repr(u8)]
29
+ #[allow(dead_code)]
30
+ enum WithWraparoundInvalidValues {
31
+ X = 1,
32
+ Y = 254,
33
+ }
34
+
35
36
+ enum Foo {
37
+ A,
38
+ B,
39
+ C(WithWraparoundInvalidValues),
40
41
42
+ let x = Foo::B;
43
+ if let Foo::C(_) = x {
44
+ panic!();
45
46
+}
47
48
fn main() {
49
test(MyEnum::MyEmptyVariant);
50
test(MyEnum::MyNewtypeVariant(42));
@@ -31,4 +53,6 @@ fn main() {
53
my_first_field: 45,
54
my_second_field: 46,
55
});
56
57
+ discriminant_overflow();
58
0 commit comments