]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0696.md
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0696.md
1 A function is using `continue` keyword incorrectly.
2
3 Erroneous code example:
4
5 ```compile_fail,E0696
6 fn continue_simple() {
7     'b: {
8         continue; // error!
9     }
10 }
11 fn continue_labeled() {
12     'b: {
13         continue 'b; // error!
14     }
15 }
16 fn continue_crossing() {
17     loop {
18         'b: {
19             continue; // error!
20         }
21     }
22 }
23 ```
24
25 Here we have used the `continue` keyword incorrectly. As we
26 have seen above that `continue` pointing to a labeled block.
27
28 To fix this we have to use the labeled block properly.
29 For example:
30
31 ```
32 fn continue_simple() {
33     'b: loop {
34         continue ; // ok!
35     }
36 }
37 fn continue_labeled() {
38     'b: loop {
39         continue 'b; // ok!
40     }
41 }
42 fn continue_crossing() {
43     loop {
44         'b: loop {
45             continue; // ok!
46         }
47     }
48 }
49 ```