Skip to content

Commit 65b7ba5

Browse files
committed
parser: add note for 'label expr.
1 parent 83be689 commit 65b7ba5

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/librustc_parse/parser/expr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,7 @@ impl<'a> Parser<'a> {
11211121
": ".to_string(),
11221122
Applicability::MachineApplicable,
11231123
)
1124+
.note("labels are used before loops and blocks, allowing e.g., `break 'label` to them")
11241125
.emit();
11251126
}
11261127

src/test/ui/parser/labeled-no-colon-expr.stderr

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ LL | 'l0 while false {}
66
| | |
77
| | help: add `:` after the label
88
| the label
9+
|
10+
= note: labels are used before loops and blocks, allowing e.g., `break 'label` to them
911

1012
error: labeled expression must be followed by `:`
1113
--> $DIR/labeled-no-colon-expr.rs:5:5
@@ -15,6 +17,8 @@ LL | 'l1 for _ in 0..1 {}
1517
| | |
1618
| | help: add `:` after the label
1719
| the label
20+
|
21+
= note: labels are used before loops and blocks, allowing e.g., `break 'label` to them
1822

1923
error: labeled expression must be followed by `:`
2024
--> $DIR/labeled-no-colon-expr.rs:6:5
@@ -24,6 +28,8 @@ LL | 'l2 loop {}
2428
| | |
2529
| | help: add `:` after the label
2630
| the label
31+
|
32+
= note: labels are used before loops and blocks, allowing e.g., `break 'label` to them
2733

2834
error: labeled expression must be followed by `:`
2935
--> $DIR/labeled-no-colon-expr.rs:7:5
@@ -33,6 +39,8 @@ LL | 'l3 {}
3339
| | |
3440
| | help: add `:` after the label
3541
| the label
42+
|
43+
= note: labels are used before loops and blocks, allowing e.g., `break 'label` to them
3644

3745
error: expected `while`, `for`, `loop` or `{` after a label
3846
--> $DIR/labeled-no-colon-expr.rs:8:9
@@ -48,6 +56,8 @@ LL | 'l4 0;
4856
| | |
4957
| | help: add `:` after the label
5058
| the label
59+
|
60+
= note: labels are used before loops and blocks, allowing e.g., `break 'label` to them
5161

5262
error: cannot use a `block` macro fragment here
5363
--> $DIR/labeled-no-colon-expr.rs:13:17
@@ -72,6 +82,8 @@ LL | 'l5 $b;
7282
...
7383
LL | m!({});
7484
| ^^
85+
|
86+
= note: labels are used before loops and blocks, allowing e.g., `break 'label` to them
7587

7688
error: aborting due to 8 previous errors
7789

0 commit comments

Comments
 (0)