Fix unsound optimization with explicit variant discriminants

This commit is contained in:
Fabian Wolff 2021-10-03 15:29:56 +02:00
parent edebf77e00
commit 529c35331b
2 changed files with 32 additions and 4 deletions

View file

@ -0,0 +1,18 @@
// Regression test for issue #89485.
// run-pass
#[derive(Debug, Eq, PartialEq)]
pub enum Type {
A = 1,
B = 2,
}
pub fn encode(v: Type) -> Type {
match v {
Type::A => Type::B,
_ => v,
}
}
fn main() {
assert_eq!(Type::B, encode(Type::A));
}