Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Stop warning against unrelated labels.
  • Loading branch information
cjgillot committed Jun 2, 2022
commit be40b588953df73a9e766b644b7eac9e7d287b99
1 change: 0 additions & 1 deletion compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3151,7 +3151,6 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
diagnostics::signal_label_shadowing(self.r.session, orig_ident, label.ident)
}
if rib.kind.is_label_barrier() {
rib.bindings.insert(ident, id);
break;
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/test/ui/hygiene/hygienic-labels-in-let.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ pub fn main() {

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

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

let n: isize = {
'x: for _ in 0..1 {
//~^ WARNING shadows a label name that is already in scope
// ditto
run_once!(continue 'x);
i += 1;
Expand Down
29 changes: 0 additions & 29 deletions src/test/ui/hygiene/hygienic-labels-in-let.stderr

This file was deleted.

6 changes: 0 additions & 6 deletions src/test/ui/hygiene/hygienic-labels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,17 @@ pub fn main() {
}

'x: loop {
//~^ WARNING shadows a label name that is already in scope

// ditto
loop_x!(break 'x);
panic!("break doesn't act hygienically inside infinite loop");
}

'x: while 1 + 1 == 2 {
//~^ WARNING shadows a label name that is already in scope

while_x!(break 'x);
panic!("break doesn't act hygienically inside infinite while loop");
}

'x: for _ in 0..1 {
//~^ WARNING shadows a label name that is already in scope

// ditto
run_once!(continue 'x);
panic!("continue doesn't act hygienically inside for loop");
Expand Down
29 changes: 0 additions & 29 deletions src/test/ui/hygiene/hygienic-labels.stderr

This file was deleted.

96 changes: 24 additions & 72 deletions src/test/ui/label/label_misspelled.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ error[E0425]: cannot find value `while_loop` in this scope
--> $DIR/label_misspelled.rs:6:9
|
LL | 'while_loop: while true {
| -----------
| |
| a label with a similar name exists
| a label with a similar name exists
| ----------- a label with a similar name exists
LL |
LL | while_loop;
| ^^^^^^^^^^ not found in this scope
Expand All @@ -14,10 +11,7 @@ error[E0425]: cannot find value `while_let` in this scope
--> $DIR/label_misspelled.rs:11:9
|
LL | 'while_let: while let Some(_) = Some(()) {
| ----------
| |
| a label with a similar name exists
| a label with a similar name exists
| ---------- a label with a similar name exists
LL |
LL | while_let;
| ^^^^^^^^^ not found in this scope
Expand All @@ -26,10 +20,7 @@ error[E0425]: cannot find value `for_loop` in this scope
--> $DIR/label_misspelled.rs:16:9
|
LL | 'for_loop: for _ in 0..3 {
| ---------
| |
| a label with a similar name exists
| a label with a similar name exists
| --------- a label with a similar name exists
LL |
LL | for_loop;
| ^^^^^^^^ not found in this scope
Expand All @@ -38,10 +29,7 @@ error[E0425]: cannot find value `LOOP` in this scope
--> $DIR/label_misspelled.rs:21:9
|
LL | 'LOOP: loop {
| -----
| |
| a label with a similar name exists
| a label with a similar name exists
| ----- a label with a similar name exists
LL |
LL | LOOP;
| ^^^^ not found in this scope
Expand All @@ -50,81 +38,45 @@ error[E0425]: cannot find value `LOOP` in this scope
--> $DIR/label_misspelled.rs:28:15
|
LL | 'LOOP: loop {
| -----
| |
| a label with a similar name exists
| a label with a similar name exists
| ----- a label with a similar name exists
LL | break LOOP;
| ^^^^ not found in this scope
|
help: use the similarly named label
|
LL | break 'LOOP;
| ~~~~~
help: use the similarly named label
|
LL | break 'LOOP;
| ~~~~~
| ^^^^
| |
| not found in this scope
| help: use the similarly named label: `'LOOP`

error[E0425]: cannot find value `while_loop` in this scope
--> $DIR/label_misspelled.rs:32:15
|
LL | 'while_loop: while true {
| -----------
| |
| a label with a similar name exists
| a label with a similar name exists
| ----------- a label with a similar name exists
LL | break while_loop;
| ^^^^^^^^^^ not found in this scope
|
help: use the similarly named label
|
LL | break 'while_loop;
| ~~~~~~~~~~~
help: use the similarly named label
|
LL | break 'while_loop;
| ~~~~~~~~~~~
| ^^^^^^^^^^
| |
| not found in this scope
| help: use the similarly named label: `'while_loop`

error[E0425]: cannot find value `while_let` in this scope
--> $DIR/label_misspelled.rs:36:15
|
LL | 'while_let: while let Some(_) = Some(()) {
| ----------
| |
| a label with a similar name exists
| a label with a similar name exists
| ---------- a label with a similar name exists
LL | break while_let;
| ^^^^^^^^^ not found in this scope
|
help: use the similarly named label
|
LL | break 'while_let;
| ~~~~~~~~~~
help: use the similarly named label
|
LL | break 'while_let;
| ~~~~~~~~~~
| ^^^^^^^^^
| |
| not found in this scope
| help: use the similarly named label: `'while_let`

error[E0425]: cannot find value `for_loop` in this scope
--> $DIR/label_misspelled.rs:40:15
|
LL | 'for_loop: for _ in 0..3 {
| ---------
| |
| a label with a similar name exists
| a label with a similar name exists
| --------- a label with a similar name exists
LL | break for_loop;
| ^^^^^^^^ not found in this scope
|
help: use the similarly named label
|
LL | break 'for_loop;
| ~~~~~~~~~
help: use the similarly named label
|
LL | break 'for_loop;
| ~~~~~~~~~
| ^^^^^^^^
| |
| not found in this scope
| help: use the similarly named label: `'for_loop`

warning: unused label
--> $DIR/label_misspelled.rs:4:5
Expand Down
38 changes: 10 additions & 28 deletions src/test/ui/label/label_misspelled_2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,23 @@ error[E0425]: cannot find value `b` in this scope
--> $DIR/label_misspelled_2.rs:8:15
|
LL | 'b: for _ in 0..1 {
| --
| |
| a label with a similar name exists
| a label with a similar name exists
| -- a label with a similar name exists
LL | break b;
| ^ not found in this scope
|
help: use the similarly named label
|
LL | break 'b;
| ~~
help: use the similarly named label
|
LL | break 'b;
| ~~
| ^
| |
| not found in this scope
| help: use the similarly named label: `'b`

error[E0425]: cannot find value `d` in this scope
--> $DIR/label_misspelled_2.rs:14:15
|
LL | d: for _ in 0..1 {
| -
| |
| a label with a similar name exists
| a label with a similar name exists
| - a label with a similar name exists
LL | break d;
| ^ not found in this scope
|
help: use the similarly named label
|
LL | break 'd;
| ~~
help: use the similarly named label
|
LL | break 'd;
| ~~
| ^
| |
| not found in this scope
| help: use the similarly named label: `'d`

error: aborting due to 4 previous errors

Expand Down
1 change: 0 additions & 1 deletion src/test/ui/lint/unused_labels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ fn main() {
//~^ WARN unused label
'many_used_shadowed: for _ in 0..10 {
//~^ WARN label name `'many_used_shadowed` shadows a label name that is already in scope
//~| WARN label name `'many_used_shadowed` shadows a label name that is already in scope
if 1 % 2 == 0 {
break 'many_used_shadowed;
} else {
Expand Down
15 changes: 3 additions & 12 deletions src/test/ui/lint/unused_labels.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@ LL |
LL | 'many_used_shadowed: for _ in 0..10 {
| ^^^^^^^^^^^^^^^^^^^ label `'many_used_shadowed` already in scope

warning: label name `'many_used_shadowed` shadows a label name that is already in scope
--> $DIR/unused_labels.rs:62:9
|
LL | 'many_used_shadowed: for _ in 0..10 {
| ------------------- first declared here
LL |
LL | 'many_used_shadowed: for _ in 0..10 {
| ^^^^^^^^^^^^^^^^^^^ label `'many_used_shadowed` already in scope

warning: unused label
--> $DIR/unused_labels.rs:11:5
|
Expand Down Expand Up @@ -59,16 +50,16 @@ LL | 'many_used_shadowed: for _ in 0..10 {
| ^^^^^^^^^^^^^^^^^^^

warning: unused label
--> $DIR/unused_labels.rs:73:5
--> $DIR/unused_labels.rs:72:5
|
LL | 'unused_loop_label: loop {
| ^^^^^^^^^^^^^^^^^^

warning: unused label
--> $DIR/unused_labels.rs:79:5
--> $DIR/unused_labels.rs:78:5
|
LL | 'unused_block_label: {
| ^^^^^^^^^^^^^^^^^^^

warning: 10 warnings emitted
warning: 9 warnings emitted

19 changes: 5 additions & 14 deletions src/test/ui/loops/loop-break-value.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,12 @@ error[E0425]: cannot find value `LOOP` in this scope
--> $DIR/loop-break-value.rs:95:15
|
LL | 'LOOP: for _ in 0 .. 9 {
| -----
| |
| a label with a similar name exists
| a label with a similar name exists
| ----- a label with a similar name exists
LL | break LOOP;
| ^^^^ not found in this scope
|
help: use the similarly named label
|
LL | break 'LOOP;
| ~~~~~
help: use the similarly named label
|
LL | break 'LOOP;
| ~~~~~
| ^^^^
| |
| not found in this scope
| help: use the similarly named label: `'LOOP`

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