Skip to content

Commit 7939a4d

Browse files
authored
Rollup merge of rust-lang#71370 - PankajChaudhary5:ErrorCode-E0696, r=GuillaumeGomez
Added detailed error code explanation for issue E0696 in Rust compiler. Added proper error explanation for issue E0696 in the Rust compiler. Error Code E0696 Sub Part of Issue rust-lang#61137 r? @GuillaumeGomez
2 parents 221f677 + e5b68bc commit 7939a4d

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

src/librustc_error_codes/error_codes.rs

Lines changed: 1 addition & 1 deletion
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"),
@@ -604,7 +605,6 @@ E0753: include_str!("./error_codes/E0753.md"),
604605
E0687, // in-band lifetimes cannot be used in `fn`/`Fn` syntax
605606
E0688, // in-band lifetimes cannot be mixed with explicit lifetime binders
606607
// E0694, // an unknown tool name found in scoped attributes
607-
E0696, // `continue` pointing to a labeled block
608608
// E0702, // replaced with a generic attribute input check
609609
// E0707, // multiple elided lifetimes used in arguments of `async fn`
610610
// E0709, // multiple different lifetimes used in arguments of `async fn`
Lines changed: 49 additions & 0 deletions
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

Lines changed: 2 additions & 1 deletion
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)