Skip to content

Commit be40b58

Browse files
committed
Stop warning against unrelated labels.
1 parent 84e1993 commit be40b58

14 files changed

+42
-428
lines changed

compiler/rustc_resolve/src/late.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3151,7 +3151,6 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
31513151
diagnostics::signal_label_shadowing(self.r.session, orig_ident, label.ident)
31523152
}
31533153
if rib.kind.is_label_barrier() {
3154-
rib.bindings.insert(ident, id);
31553154
break;
31563155
}
31573156
}

src/test/ui/hygiene/hygienic-labels-in-let.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ pub fn main() {
5252

5353
let k: isize = {
5454
'x: for _ in 0..1 {
55-
//~^ WARNING shadows a label name that is already in scope
5655
// ditto
5756
loop_x!(break 'x);
5857
i += 1;
@@ -63,7 +62,6 @@ pub fn main() {
6362

6463
let l: isize = {
6564
'x: for _ in 0..1 {
66-
//~^ WARNING shadows a label name that is already in scope
6765
// ditto
6866
while_true!(break 'x);
6967
i += 1;
@@ -74,7 +72,6 @@ pub fn main() {
7472

7573
let n: isize = {
7674
'x: for _ in 0..1 {
77-
//~^ WARNING shadows a label name that is already in scope
7875
// ditto
7976
run_once!(continue 'x);
8077
i += 1;

src/test/ui/hygiene/hygienic-labels-in-let.stderr

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/test/ui/hygiene/hygienic-labels.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,17 @@ pub fn main() {
4242
}
4343

4444
'x: loop {
45-
//~^ WARNING shadows a label name that is already in scope
46-
4745
// ditto
4846
loop_x!(break 'x);
4947
panic!("break doesn't act hygienically inside infinite loop");
5048
}
5149

5250
'x: while 1 + 1 == 2 {
53-
//~^ WARNING shadows a label name that is already in scope
54-
5551
while_x!(break 'x);
5652
panic!("break doesn't act hygienically inside infinite while loop");
5753
}
5854

5955
'x: for _ in 0..1 {
60-
//~^ WARNING shadows a label name that is already in scope
61-
6256
// ditto
6357
run_once!(continue 'x);
6458
panic!("continue doesn't act hygienically inside for loop");

src/test/ui/hygiene/hygienic-labels.stderr

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/test/ui/label/label_misspelled.stderr

Lines changed: 24 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ error[E0425]: cannot find value `while_loop` in this scope
22
--> $DIR/label_misspelled.rs:6:9
33
|
44
LL | 'while_loop: while true {
5-
| -----------
6-
| |
7-
| a label with a similar name exists
8-
| a label with a similar name exists
5+
| ----------- a label with a similar name exists
96
LL |
107
LL | while_loop;
118
| ^^^^^^^^^^ not found in this scope
@@ -14,10 +11,7 @@ error[E0425]: cannot find value `while_let` in this scope
1411
--> $DIR/label_misspelled.rs:11:9
1512
|
1613
LL | 'while_let: while let Some(_) = Some(()) {
17-
| ----------
18-
| |
19-
| a label with a similar name exists
20-
| a label with a similar name exists
14+
| ---------- a label with a similar name exists
2115
LL |
2216
LL | while_let;
2317
| ^^^^^^^^^ not found in this scope
@@ -26,10 +20,7 @@ error[E0425]: cannot find value `for_loop` in this scope
2620
--> $DIR/label_misspelled.rs:16:9
2721
|
2822
LL | 'for_loop: for _ in 0..3 {
29-
| ---------
30-
| |
31-
| a label with a similar name exists
32-
| a label with a similar name exists
23+
| --------- a label with a similar name exists
3324
LL |
3425
LL | for_loop;
3526
| ^^^^^^^^ not found in this scope
@@ -38,10 +29,7 @@ error[E0425]: cannot find value `LOOP` in this scope
3829
--> $DIR/label_misspelled.rs:21:9
3930
|
4031
LL | 'LOOP: loop {
41-
| -----
42-
| |
43-
| a label with a similar name exists
44-
| a label with a similar name exists
32+
| ----- a label with a similar name exists
4533
LL |
4634
LL | LOOP;
4735
| ^^^^ not found in this scope
@@ -50,81 +38,45 @@ error[E0425]: cannot find value `LOOP` in this scope
5038
--> $DIR/label_misspelled.rs:28:15
5139
|
5240
LL | 'LOOP: loop {
53-
| -----
54-
| |
55-
| a label with a similar name exists
56-
| a label with a similar name exists
41+
| ----- a label with a similar name exists
5742
LL | break LOOP;
58-
| ^^^^ not found in this scope
59-
|
60-
help: use the similarly named label
61-
|
62-
LL | break 'LOOP;
63-
| ~~~~~
64-
help: use the similarly named label
65-
|
66-
LL | break 'LOOP;
67-
| ~~~~~
43+
| ^^^^
44+
| |
45+
| not found in this scope
46+
| help: use the similarly named label: `'LOOP`
6847

6948
error[E0425]: cannot find value `while_loop` in this scope
7049
--> $DIR/label_misspelled.rs:32:15
7150
|
7251
LL | 'while_loop: while true {
73-
| -----------
74-
| |
75-
| a label with a similar name exists
76-
| a label with a similar name exists
52+
| ----------- a label with a similar name exists
7753
LL | break while_loop;
78-
| ^^^^^^^^^^ not found in this scope
79-
|
80-
help: use the similarly named label
81-
|
82-
LL | break 'while_loop;
83-
| ~~~~~~~~~~~
84-
help: use the similarly named label
85-
|
86-
LL | break 'while_loop;
87-
| ~~~~~~~~~~~
54+
| ^^^^^^^^^^
55+
| |
56+
| not found in this scope
57+
| help: use the similarly named label: `'while_loop`
8858

8959
error[E0425]: cannot find value `while_let` in this scope
9060
--> $DIR/label_misspelled.rs:36:15
9161
|
9262
LL | 'while_let: while let Some(_) = Some(()) {
93-
| ----------
94-
| |
95-
| a label with a similar name exists
96-
| a label with a similar name exists
63+
| ---------- a label with a similar name exists
9764
LL | break while_let;
98-
| ^^^^^^^^^ not found in this scope
99-
|
100-
help: use the similarly named label
101-
|
102-
LL | break 'while_let;
103-
| ~~~~~~~~~~
104-
help: use the similarly named label
105-
|
106-
LL | break 'while_let;
107-
| ~~~~~~~~~~
65+
| ^^^^^^^^^
66+
| |
67+
| not found in this scope
68+
| help: use the similarly named label: `'while_let`
10869

10970
error[E0425]: cannot find value `for_loop` in this scope
11071
--> $DIR/label_misspelled.rs:40:15
11172
|
11273
LL | 'for_loop: for _ in 0..3 {
113-
| ---------
114-
| |
115-
| a label with a similar name exists
116-
| a label with a similar name exists
74+
| --------- a label with a similar name exists
11775
LL | break for_loop;
118-
| ^^^^^^^^ not found in this scope
119-
|
120-
help: use the similarly named label
121-
|
122-
LL | break 'for_loop;
123-
| ~~~~~~~~~
124-
help: use the similarly named label
125-
|
126-
LL | break 'for_loop;
127-
| ~~~~~~~~~
76+
| ^^^^^^^^
77+
| |
78+
| not found in this scope
79+
| help: use the similarly named label: `'for_loop`
12880

12981
warning: unused label
13082
--> $DIR/label_misspelled.rs:4:5

src/test/ui/label/label_misspelled_2.stderr

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,23 @@ error[E0425]: cannot find value `b` in this scope
1414
--> $DIR/label_misspelled_2.rs:8:15
1515
|
1616
LL | 'b: for _ in 0..1 {
17-
| --
18-
| |
19-
| a label with a similar name exists
20-
| a label with a similar name exists
17+
| -- a label with a similar name exists
2118
LL | break b;
22-
| ^ not found in this scope
23-
|
24-
help: use the similarly named label
25-
|
26-
LL | break 'b;
27-
| ~~
28-
help: use the similarly named label
29-
|
30-
LL | break 'b;
31-
| ~~
19+
| ^
20+
| |
21+
| not found in this scope
22+
| help: use the similarly named label: `'b`
3223

3324
error[E0425]: cannot find value `d` in this scope
3425
--> $DIR/label_misspelled_2.rs:14:15
3526
|
3627
LL | d: for _ in 0..1 {
37-
| -
38-
| |
39-
| a label with a similar name exists
40-
| a label with a similar name exists
28+
| - a label with a similar name exists
4129
LL | break d;
42-
| ^ not found in this scope
43-
|
44-
help: use the similarly named label
45-
|
46-
LL | break 'd;
47-
| ~~
48-
help: use the similarly named label
49-
|
50-
LL | break 'd;
51-
| ~~
30+
| ^
31+
| |
32+
| not found in this scope
33+
| help: use the similarly named label: `'d`
5234

5335
error: aborting due to 4 previous errors
5436

src/test/ui/lint/unused_labels.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ fn main() {
6161
//~^ WARN unused label
6262
'many_used_shadowed: for _ in 0..10 {
6363
//~^ WARN label name `'many_used_shadowed` shadows a label name that is already in scope
64-
//~| WARN label name `'many_used_shadowed` shadows a label name that is already in scope
6564
if 1 % 2 == 0 {
6665
break 'many_used_shadowed;
6766
} else {

src/test/ui/lint/unused_labels.stderr

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@ LL |
77
LL | 'many_used_shadowed: for _ in 0..10 {
88
| ^^^^^^^^^^^^^^^^^^^ label `'many_used_shadowed` already in scope
99

10-
warning: label name `'many_used_shadowed` shadows a label name that is already in scope
11-
--> $DIR/unused_labels.rs:62:9
12-
|
13-
LL | 'many_used_shadowed: for _ in 0..10 {
14-
| ------------------- first declared here
15-
LL |
16-
LL | 'many_used_shadowed: for _ in 0..10 {
17-
| ^^^^^^^^^^^^^^^^^^^ label `'many_used_shadowed` already in scope
18-
1910
warning: unused label
2011
--> $DIR/unused_labels.rs:11:5
2112
|
@@ -59,16 +50,16 @@ LL | 'many_used_shadowed: for _ in 0..10 {
5950
| ^^^^^^^^^^^^^^^^^^^
6051

6152
warning: unused label
62-
--> $DIR/unused_labels.rs:73:5
53+
--> $DIR/unused_labels.rs:72:5
6354
|
6455
LL | 'unused_loop_label: loop {
6556
| ^^^^^^^^^^^^^^^^^^
6657

6758
warning: unused label
68-
--> $DIR/unused_labels.rs:79:5
59+
--> $DIR/unused_labels.rs:78:5
6960
|
7061
LL | 'unused_block_label: {
7162
| ^^^^^^^^^^^^^^^^^^^
7263

73-
warning: 10 warnings emitted
64+
warning: 9 warnings emitted
7465

src/test/ui/loops/loop-break-value.stderr

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,12 @@ error[E0425]: cannot find value `LOOP` in this scope
22
--> $DIR/loop-break-value.rs:95:15
33
|
44
LL | 'LOOP: for _ in 0 .. 9 {
5-
| -----
6-
| |
7-
| a label with a similar name exists
8-
| a label with a similar name exists
5+
| ----- a label with a similar name exists
96
LL | break LOOP;
10-
| ^^^^ not found in this scope
11-
|
12-
help: use the similarly named label
13-
|
14-
LL | break 'LOOP;
15-
| ~~~~~
16-
help: use the similarly named label
17-
|
18-
LL | break 'LOOP;
19-
| ~~~~~
7+
| ^^^^
8+
| |
9+
| not found in this scope
10+
| help: use the similarly named label: `'LOOP`
2011

2112
warning: denote infinite loops with `loop { ... }`
2213
--> $DIR/loop-break-value.rs:26:5

0 commit comments

Comments
 (0)