forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For OutsideLoop we should not suggest add
'block
label in if
bloc…
…k, or we wiil get another err: block label not supported here. fixes rust-lang#123261
- Loading branch information
Showing
4 changed files
with
169 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//@ run-rustfix | ||
|
||
#![allow(unused)] | ||
|
||
fn main() { | ||
let n = 1; | ||
let x = 'block: { | ||
if n == 0 { | ||
break 'block 1; //~ ERROR [E0268] | ||
} else { | ||
break 'block 2; //~ ERROR [E0268] | ||
} | ||
}; | ||
|
||
let y = 'block: { | ||
if n == 0 { | ||
break 'block 1; //~ ERROR [E0268] | ||
} | ||
break 'block 0; //~ ERROR [E0268] | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//@ run-rustfix | ||
|
||
#![allow(unused)] | ||
|
||
fn main() { | ||
let n = 1; | ||
let x = { | ||
if n == 0 { | ||
break 1; //~ ERROR [E0268] | ||
} else { | ||
break 2; //~ ERROR [E0268] | ||
} | ||
}; | ||
|
||
let y = { | ||
if n == 0 { | ||
break 1; //~ ERROR [E0268] | ||
} | ||
break 0; //~ ERROR [E0268] | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
error[E0268]: `break` outside of a loop or labeled block | ||
--> $DIR/loop-if-else-break-issue-123261.rs:9:13 | ||
| | ||
LL | break 1; | ||
| ^^^^^^^ cannot `break` outside of a loop or labeled block | ||
| | ||
help: consider labeling this block to be able to break within it | ||
| | ||
LL ~ let x = 'block: { | ||
LL | if n == 0 { | ||
LL ~ break 'block 1; | ||
| | ||
|
||
error[E0268]: `break` outside of a loop or labeled block | ||
--> $DIR/loop-if-else-break-issue-123261.rs:11:13 | ||
| | ||
LL | break 2; | ||
| ^^^^^^^ cannot `break` outside of a loop or labeled block | ||
| | ||
help: consider labeling this block to be able to break within it | ||
| | ||
LL ~ 'block: //@ run-rustfix | ||
LL | | ||
... | ||
LL | } else { | ||
LL ~ break 'block 2; | ||
| | ||
|
||
error[E0268]: `break` outside of a loop or labeled block | ||
--> $DIR/loop-if-else-break-issue-123261.rs:17:13 | ||
| | ||
LL | break 1; | ||
| ^^^^^^^ cannot `break` outside of a loop or labeled block | ||
| | ||
help: consider labeling this block to be able to break within it | ||
| | ||
LL ~ let y = 'block: { | ||
LL | if n == 0 { | ||
LL ~ break 'block 1; | ||
| | ||
|
||
error[E0268]: `break` outside of a loop or labeled block | ||
--> $DIR/loop-if-else-break-issue-123261.rs:19:9 | ||
| | ||
LL | break 0; | ||
| ^^^^^^^ cannot `break` outside of a loop or labeled block | ||
| | ||
help: consider labeling this block to be able to break within it | ||
| | ||
LL ~ 'block: //@ run-rustfix | ||
LL | | ||
... | ||
LL | } | ||
LL ~ break 'block 0; | ||
| | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0268`. |