From 64d98f8ee037282c35007b64c2649055c56af1db Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:03 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/mir/issue-77359-simplify-arm-identity.rs | 35 +++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/ui/mir/issue-77359-simplify-arm-identity.rs (limited to 'tests/ui/mir/issue-77359-simplify-arm-identity.rs') diff --git a/tests/ui/mir/issue-77359-simplify-arm-identity.rs b/tests/ui/mir/issue-77359-simplify-arm-identity.rs new file mode 100644 index 000000000..e58ba50a9 --- /dev/null +++ b/tests/ui/mir/issue-77359-simplify-arm-identity.rs @@ -0,0 +1,35 @@ +// run-pass + +#![allow(dead_code)] + +#[derive(Debug)] +enum MyEnum { + Variant1(Vec), + Variant2, + Variant3, + Variant4, +} + +fn f(arg1: &bool, arg2: &bool, arg3: bool) -> MyStruct { + if *arg1 { + println!("{:?}", f(&arg2, arg2, arg3)); + MyStruct(None) + } else { + match if arg3 { Some(MyEnum::Variant3) } else { None } { + Some(t) => { + let ah = t; + return MyStruct(Some(ah)); + } + _ => MyStruct(None) + } + } +} + +#[derive(Debug)] +struct MyStruct(Option); + +fn main() { + let arg1 = true; + let arg2 = false; + f(&arg1, &arg2, true); +} -- cgit v1.2.3