-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added proper explanation error code E0696
- Loading branch information
1 parent
20fc02f
commit e5b68bc
Showing
3 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
A function is using `continue` keyword incorrectly. | ||
|
||
Erroneous code example: | ||
|
||
```compile_fail,E0696 | ||
fn continue_simple() { | ||
'b: { | ||
continue; // error! | ||
} | ||
} | ||
fn continue_labeled() { | ||
'b: { | ||
continue 'b; // error! | ||
} | ||
} | ||
fn continue_crossing() { | ||
loop { | ||
'b: { | ||
continue; // error! | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Here we have used the `continue` keyword incorrectly. As we | ||
have seen above that `continue` pointing to a labeled block. | ||
|
||
To fix this we have to use the labeled block properly. | ||
For example: | ||
|
||
``` | ||
fn continue_simple() { | ||
'b: loop { | ||
continue ; // ok! | ||
} | ||
} | ||
fn continue_labeled() { | ||
'b: loop { | ||
continue 'b; // ok! | ||
} | ||
} | ||
fn continue_crossing() { | ||
loop { | ||
'b: loop { | ||
continue; // ok! | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters