-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #106783 - WaffleLapkin:break-my-ident, r=wesleywiser
Recover labels written as identifiers This adds recovery for `break label expr` and `continue label`, as well as a test for `break label`.
- Loading branch information
Showing
4 changed files
with
93 additions
and
7 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,7 @@ | ||
// run-rustfix | ||
|
||
fn main() { | ||
'label: loop { break 'label }; //~ error: cannot find value `label` in this scope | ||
'label: loop { break 'label 0 }; //~ error: expected a label, found an identifier | ||
'label: loop { continue 'label }; //~ error: expected a label, found an identifier | ||
} |
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,7 @@ | ||
// run-rustfix | ||
|
||
fn main() { | ||
'label: loop { break label }; //~ error: cannot find value `label` in this scope | ||
'label: loop { break label 0 }; //~ error: expected a label, found an identifier | ||
'label: loop { continue label }; //~ error: expected a label, found an identifier | ||
} |
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,25 @@ | ||
error: expected a label, found an identifier | ||
--> $DIR/recover-unticked-labels.rs:5:26 | ||
| | ||
LL | 'label: loop { break label 0 }; | ||
| ^^^^^ help: labels start with a tick: `'label` | ||
|
||
error: expected a label, found an identifier | ||
--> $DIR/recover-unticked-labels.rs:6:29 | ||
| | ||
LL | 'label: loop { continue label }; | ||
| ^^^^^ help: labels start with a tick: `'label` | ||
|
||
error[E0425]: cannot find value `label` in this scope | ||
--> $DIR/recover-unticked-labels.rs:4:26 | ||
| | ||
LL | 'label: loop { break label }; | ||
| ------ ^^^^^ | ||
| | | | ||
| | not found in this scope | ||
| | help: use the similarly named label: `'label` | ||
| a label with a similar name exists | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0425`. |