Skip to content

Commit 8b7d2bc

Browse files
Add E0744 for control flow in consts
1 parent 695fe96 commit 8b7d2bc

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/librustc_passes/error_codes.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,28 @@ async fn foo() {}
626626
Switch to the Rust 2018 edition to use `async fn`.
627627
"##,
628628

629+
E0744: r##"
630+
Control-flow expressions are not allowed inside a const context.
631+
632+
At the moment, `if` and `match`, as well as the looping constructs `for`,
633+
`while`, and `loop`, are forbidden inside a `const`, `static`, or `const fn`.
634+
635+
```compile_fail,E0744
636+
const _: {
637+
let mut x = 0;
638+
loop {
639+
x += 1;
640+
if x == 4 {
641+
break;
642+
}
643+
}
644+
645+
x
646+
};
647+
```
648+
649+
"##,
650+
629651
;
630652
E0226, // only a single explicit lifetime bound is permitted
631653
E0472, // asm! is unsupported on this target

0 commit comments

Comments
 (0)