diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2019-11-14 00:26:16 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2019-11-14 13:05:56 +0100 |
| commit | bfa3d599ebf4be6348c2a4d6ffa8f32f61ab7c15 (patch) | |
| tree | 599c06299479869d2f994f3ff89cf204af56d886 | |
| parent | 27b58edc2391c6ff3779c09790ac7e38d8c6daac (diff) | |
| download | rust-bfa3d599ebf4be6348c2a4d6ffa8f32f61ab7c15.tar.gz rust-bfa3d599ebf4be6348c2a4d6ffa8f32f61ab7c15.zip | |
move E0744 to new error code
| -rw-r--r-- | src/librustc_error_codes/error_codes.rs | 1 | ||||
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0744.md | 17 | ||||
| -rw-r--r-- | src/librustc_passes/check_const.rs | 1 |
3 files changed, 19 insertions, 0 deletions
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 @@ E0740: include_str!("./error_codes/E0740.md"), 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 rustc::ty::query::Providers; use syntax::ast::Mutability; use syntax::span_err; use syntax_pos::Span; +use rustc_error_codes::*; use std::fmt; |
