From eb36f5ee5b71cbe3eb356f8e56e9c9a69b6d649d Mon Sep 17 00:00:00 2001 From: Ding Xiang Fei Date: Sun, 18 Sep 2022 12:18:34 +0800 Subject: [PATCH] add miri test via const fn --- src/test/mir-opt/issue-101867.rs | 2 +- src/test/ui/let-else/const-fn.rs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/let-else/const-fn.rs diff --git a/src/test/mir-opt/issue-101867.rs b/src/test/mir-opt/issue-101867.rs index 98f9aa6ef40ac..931396e2171f0 100644 --- a/src/test/mir-opt/issue-101867.rs +++ b/src/test/mir-opt/issue-101867.rs @@ -1,4 +1,4 @@ -#![feature(let_else)] +#![cfg_attr(bootstrap, feature(let_else))] // EMIT_MIR issue_101867.main.mir_map.0.mir fn main() { diff --git a/src/test/ui/let-else/const-fn.rs b/src/test/ui/let-else/const-fn.rs new file mode 100644 index 0000000000000..336b0b4b72ad5 --- /dev/null +++ b/src/test/ui/let-else/const-fn.rs @@ -0,0 +1,19 @@ +// run-pass +// issue #101932 + +#![cfg_attr(bootstrap, feature(let_else))] + +const fn foo(a: Option) -> i32 { + let Some(a) = a else { + return 42 + }; + + a + 1 +} + +fn main() { + const A: i32 = foo(None); + const B: i32 = foo(Some(1)); + + println!("{} {}", A, B); +}