-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.WG-diagnosticsWorking group: DiagnosticsWorking group: Diagnostics
Description
Consider the following code:
fn main() {
'break: loop {
}
}
The loop label is illegal, as it is a reserved keyword. The compiler recognizes this, but the error message claims 'break
to be a lifetime, and not a loop label:
Compiling playground v0.0.1 (file:///playground)
error: lifetimes cannot use keyword names
--> src/main.rs:2:6
|
2 | 'break: loop {
| ^^^^^
error: aborting due to previous error
error: Could not compile `playground`.
To learn more, run the command again with --verbose.
I took a quick look in libsyntax, and it seems that the problem is that 'break
and :
are two tokens, and that we don't figure out that it's a label instead of a lifetime until parsing.
Meta
This applies to stable, beta, nightly, and presumably master.
Ixrec, Lymia, scottmcm and kennytm
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.WG-diagnosticsWorking group: DiagnosticsWorking group: Diagnostics