From bfa3d599ebf4be6348c2a4d6ffa8f32f61ab7c15 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 14 Nov 2019 00:26:16 +0100 Subject: [PATCH] move E0744 to new error code --- src/librustc_error_codes/error_codes.rs | 1 + src/librustc_error_codes/error_codes/E0744.md | 17 +++++++++++++++++ src/librustc_passes/check_const.rs | 1 + 3 files changed, 19 insertions(+) create mode 100644 src/librustc_error_codes/error_codes/E0744.md diff --git a/src/librustc_error_codes/error_codes.rs b/src/librustc_error_codes/error_codes.rs index e8d5499ac58..5e6d5ce159d 100644 --- a/src/librustc_error_codes/error_codes.rs +++ b/src/librustc_error_codes/error_codes.rs @@ -401,6 +401,7 @@ E0741: include_str!("./error_codes/E0741.md"), E0742: include_str!("./error_codes/E0742.md"), E0743: include_str!("./error_codes/E0743.md"), +E0744: include_str!("./error_codes/E0744.md"), ; // E0006, // merged with E0005 // E0008, // cannot bind by-move into a pattern guard diff --git a/src/librustc_error_codes/error_codes/E0744.md b/src/librustc_error_codes/error_codes/E0744.md new file mode 100644 index 00000000000..254223f3565 --- /dev/null +++ b/src/librustc_error_codes/error_codes/E0744.md @@ -0,0 +1,17 @@ +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 _: i32 = { + let mut x = 0; + loop { + x += 1; + if x == 4 { + break; + } + } + x +}; +``` diff --git a/src/librustc_passes/check_const.rs b/src/librustc_passes/check_const.rs index a6d7eeabc88..9d37b4bdb76 100644 --- a/src/librustc_passes/check_const.rs +++ b/src/librustc_passes/check_const.rs @@ -17,6 +17,7 @@ use syntax::ast::Mutability; use syntax::span_err; use syntax_pos::Span; +use rustc_error_codes::*; use std::fmt;