Closed
Description
This is an enhancement request. This code is wrong because it lacks a ':
fn main() {
'LOOP: for _ in 0 .. 9 {
break LOOP;
}
}
It gives the error messages (rustc 1.50.0-nightly 1c389ff 2020-11-24):
error[E0425]: cannot find value `LOOP` in this scope
--> ...test.rs:3:15
|
3 | break LOOP;
| ^^^^ not found in this scope
warning: unused label
--> ...test.rs:2:5
|
2 | 'LOOP: for _ in 0 .. 9 {
| ^^^^^
|
= note: `#[warn(unused_labels)]` on by default
error[E0571]: `break` with value from a `for` loop
--> ...test.rs:3:9
|
3 | break LOOP;
| ^^^^^^^^^^ can only break with a value inside `loop` or breakable block
|
help: instead, use `break` on its own without a value inside this `for` loop
|
3 | break;
| ^^^^^
error: aborting due to 2 previous errors; 1 warning emitted
But in such case I think it's better for the compiler to recognize in the error messages that the problem is probably just a lack of ' instead.