From af591ebe4d0cf2097a5fdc0bb710442d0f2e7876 Mon Sep 17 00:00:00 2001 From: Ding Xiang Fei Date: Mon, 5 Sep 2022 14:17:41 +0800 Subject: [PATCH] add test for #99975 --- src/test/ui/let-else/issue-99975.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/test/ui/let-else/issue-99975.rs diff --git a/src/test/ui/let-else/issue-99975.rs b/src/test/ui/let-else/issue-99975.rs new file mode 100644 index 0000000000000..80f6355619412 --- /dev/null +++ b/src/test/ui/let-else/issue-99975.rs @@ -0,0 +1,20 @@ +// run-pass +// compile-flags: -C opt-level=3 -Zvalidate-mir + +#![feature(let_else)] + +fn return_result() -> Option { + Some("ok".to_string()) +} + +fn start() -> String { + let Some(content) = return_result() else { + return "none".to_string() + }; + + content +} + +fn main() { + start(); +}