about summary refs log tree commit diff
path: root/src/test/ui/consts/const-if.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/consts/const-if.rs')
-rw-r--r--src/test/ui/consts/const-if.rs22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/test/ui/consts/const-if.rs b/src/test/ui/consts/const-if.rs
index 9bb5bcc499e..94cce60453d 100644
--- a/src/test/ui/consts/const-if.rs
+++ b/src/test/ui/consts/const-if.rs
@@ -1,5 +1,21 @@
-const _X: i32 = if true { 5 } else { 6 };
-//~^ ERROR constant contains unimplemented expression type
-//~| ERROR constant contains unimplemented expression type
+const _: i32 = if true { //~ ERROR `if` is not allowed in a `const`
+    5
+} else {
+    6
+};
+
+const _: i32 = match 1 { //~ ERROR `match` is not allowed in a `const`
+    2 => 3,
+    4 => 5,
+    _ => 0,
+};
+
+const fn foo() -> i32 {
+    if true { 5 } else { 6 } //~ ERROR `if` is not allowed in a `const fn`
+}
+
+const fn bar() -> i32 {
+    match 0 { 1 => 2, _ => 0 } //~ ERROR `match` is not allowed in a `const fn`
+}
 
 fn main() {}