diff options
| author | Kivooeo <Kivooeo123@gmail.com> | 2025-07-24 19:07:20 +0500 |
|---|---|---|
| committer | Kivooeo <Kivooeo123@gmail.com> | 2025-08-09 16:27:20 +0500 |
| commit | 16765639b30741dde85da0dbcb44c343eb82b1a2 (patch) | |
| tree | ef7f40e32fab78c39546bc588542774d276e5dc8 /tests/ui/codegen | |
| parent | 90bb5cacb5c1a5fe20ba821d28e7eb7a21e35d09 (diff) | |
| download | rust-16765639b30741dde85da0dbcb44c343eb82b1a2.tar.gz rust-16765639b30741dde85da0dbcb44c343eb82b1a2.zip | |
comments
Diffstat (limited to 'tests/ui/codegen')
| -rw-r--r-- | tests/ui/codegen/nested-enum-match-optimization-15793.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/ui/codegen/nested-enum-match-optimization-15793.rs b/tests/ui/codegen/nested-enum-match-optimization-15793.rs new file mode 100644 index 00000000000..420e3ad82b2 --- /dev/null +++ b/tests/ui/codegen/nested-enum-match-optimization-15793.rs @@ -0,0 +1,29 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15793 + +//@ run-pass +#![allow(dead_code)] + +enum NestedEnum { + First, + Second, + Third +} +enum Enum { + Variant1(bool), + Variant2(NestedEnum) +} + +#[inline(never)] +fn foo(x: Enum) -> isize { + match x { + Enum::Variant1(true) => 1, + Enum::Variant1(false) => 2, + Enum::Variant2(NestedEnum::Second) => 3, + Enum::Variant2(NestedEnum::Third) => 4, + Enum::Variant2(NestedEnum::First) => 5 + } +} + +fn main() { + assert_eq!(foo(Enum::Variant2(NestedEnum::Third)), 4); +} |
