Files
rust/tests/codegen-llvm/issues/issue-69174.rs
Amirhossein Akhlaghpour f849721dbd chore: add codegen test for enum clone
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
2026-07-17 18:08:12 +03:30

36 lines
534 B
Rust

// Cloning small nested enums should not require branching code.
//@ compile-flags: -Copt-level=3
#![crate_type = "lib"]
#[derive(Clone)]
pub enum Foo {
A(u8),
B(bool),
}
#[derive(Clone)]
pub enum Bar {
C(Foo),
D(u8),
}
// CHECK-LABEL: @clone_foo
// CHECK-NOT: br i1
// CHECK-NOT: switch
// CHECK: ret
#[no_mangle]
pub fn clone_foo(f: &Foo) -> Foo {
f.clone()
}
// CHECK-LABEL: @clone_bar
// CHECK-NOT: br i1
// CHECK-NOT: switch
// CHECK: ret
#[no_mangle]
pub fn clone_bar(b: &Bar) -> Bar {
b.clone()
}