Closed
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.