Skip to content

Commit e5b68bc

Browse files
committed
Added proper explanation error code E0696
1 parent 20fc02f commit e5b68bc

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

src/librustc_error_codes/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ E0691: include_str!("./error_codes/E0691.md"),
386386
E0692: include_str!("./error_codes/E0692.md"),
387387
E0693: include_str!("./error_codes/E0693.md"),
388388
E0695: include_str!("./error_codes/E0695.md"),
389+
E0696: include_str!("./error_codes/E0696.md"),
389390
E0697: include_str!("./error_codes/E0697.md"),
390391
E0698: include_str!("./error_codes/E0698.md"),
391392
E0699: include_str!("./error_codes/E0699.md"),
@@ -602,7 +603,6 @@ E0751: include_str!("./error_codes/E0751.md"),
602603
E0687, // in-band lifetimes cannot be used in `fn`/`Fn` syntax
603604
E0688, // in-band lifetimes cannot be mixed with explicit lifetime binders
604605
// E0694, // an unknown tool name found in scoped attributes
605-
E0696, // `continue` pointing to a labeled block
606606
// E0702, // replaced with a generic attribute input check
607607
// E0707, // multiple elided lifetimes used in arguments of `async fn`
608608
// E0709, // multiple different lifetimes used in arguments of `async fn`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
```

src/test/ui/label/label_break_value_continue.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ LL | continue;
2121

2222
error: aborting due to 3 previous errors
2323

24-
For more information about this error, try `rustc --explain E0695`.
24+
Some errors have detailed explanations: E0695, E0696.
25+
For more information about an error, try `rustc --explain E0695`.

0 commit comments

Comments
 (0)