about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan MacKenzie <ecstaticmorse@gmail.com>2019-11-06 11:41:27 -0800
committerDylan MacKenzie <ecstaticmorse@gmail.com>2019-11-13 10:44:13 -0800
commit8b7d2bc270af4bc873303e7c43000e49a0d5fa5a (patch)
treed117b82e973939e774d2d5f25205a58e47256f13
parent695fe965173795f9242dfcad6d1c07d7a17b106a (diff)
downloadrust-8b7d2bc270af4bc873303e7c43000e49a0d5fa5a.tar.gz
rust-8b7d2bc270af4bc873303e7c43000e49a0d5fa5a.zip
Add E0744 for control flow in consts
-rw-r--r--src/librustc_passes/error_codes.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/librustc_passes/error_codes.rs b/src/librustc_passes/error_codes.rs
index e22e69a0697..3f5b0dcab74 100644
--- a/src/librustc_passes/error_codes.rs
+++ b/src/librustc_passes/error_codes.rs
@@ -626,6 +626,28 @@ async fn foo() {}
 Switch to the Rust 2018 edition to use `async fn`.
 "##,
 
+E0744: r##"
+Control-flow expressions are not allowed inside a const context.
+
+At the moment, `if` and `match`, as well as the looping constructs `for`,
+`while`, and `loop`, are forbidden inside a `const`, `static`, or `const fn`.
+
+```compile_fail,E0744
+const _: {
+    let mut x = 0;
+    loop {
+        x += 1;
+        if x == 4 {
+            break;
+        }
+    }
+
+    x
+};
+```
+
+"##,
+
 ;
     E0226, // only a single explicit lifetime bound is permitted
     E0472, // asm! is unsupported on this target