From 37f440fd9a3d6c79647549bf559d2c19712b83d9 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Mon, 25 Nov 2019 19:44:35 -0500 Subject: [PATCH 1/2] Add wildcard test for const_if_match Closes https://github.com/rust-lang/rust/issues/66758 --- .../control-flow/single-arm-match-wild.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/test/ui/consts/control-flow/single-arm-match-wild.rs diff --git a/src/test/ui/consts/control-flow/single-arm-match-wild.rs b/src/test/ui/consts/control-flow/single-arm-match-wild.rs new file mode 100644 index 0000000000000..59a42bb05caf0 --- /dev/null +++ b/src/test/ui/consts/control-flow/single-arm-match-wild.rs @@ -0,0 +1,19 @@ +// check-pass + +#![feature(const_if_match)] + +enum E { + A, + B, + C +} + +const fn f(e: E) -> usize { + match e { + _ => 0 + } +} + +fn main() { + assert_eq!(f(E::A), 0); +} From f1f83ef8f84c15ab5292cd2dbbb0c7b0f14cbc1e Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Tue, 26 Nov 2019 12:37:55 -0500 Subject: [PATCH 2/2] Test multiple variants Co-Authored-By: Mazdak Farrokhzad --- src/test/ui/consts/control-flow/single-arm-match-wild.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/ui/consts/control-flow/single-arm-match-wild.rs b/src/test/ui/consts/control-flow/single-arm-match-wild.rs index 59a42bb05caf0..fba6e3583cc29 100644 --- a/src/test/ui/consts/control-flow/single-arm-match-wild.rs +++ b/src/test/ui/consts/control-flow/single-arm-match-wild.rs @@ -15,5 +15,7 @@ const fn f(e: E) -> usize { } fn main() { + const X: usize = f(E::C); + assert_eq!(X, 0); assert_eq!(f(E::A), 0); }