-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 #123261
- Loading branch information
Showing
6 changed files
with
243 additions
and
41 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
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,31 @@ | ||
//@ run-rustfix | ||
|
||
#![allow(unused)] | ||
|
||
fn main() { | ||
let n = 1; | ||
let m = 2; | ||
let x = 'block: { | ||
if n == 0 { | ||
break 'block 1; //~ ERROR [E0268] | ||
} else { | ||
break 'block 2; | ||
} | ||
}; | ||
|
||
let y = 'block: { | ||
if n == 0 { | ||
break 'block 1; //~ ERROR [E0268] | ||
} | ||
break 'block 0; | ||
}; | ||
|
||
let z = 'block: { | ||
if n == 0 { | ||
if m > 1 { | ||
break 'block 3; //~ ERROR [E0268] | ||
} | ||
} | ||
break 'block 1; | ||
}; | ||
} |
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,31 @@ | ||
//@ run-rustfix | ||
|
||
#![allow(unused)] | ||
|
||
fn main() { | ||
let n = 1; | ||
let m = 2; | ||
let x = { | ||
if n == 0 { | ||
break 1; //~ ERROR [E0268] | ||
} else { | ||
break 2; | ||
} | ||
}; | ||
|
||
let y = { | ||
if n == 0 { | ||
break 1; //~ ERROR [E0268] | ||
} | ||
break 0; | ||
}; | ||
|
||
let z = { | ||
if n == 0 { | ||
if m > 1 { | ||
break 3; //~ ERROR [E0268] | ||
} | ||
} | ||
break 1; | ||
}; | ||
} |
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:10:13 | ||
| | ||
LL | break 1; | ||
| ^^^^^^^ cannot `break` outside of a loop or labeled block | ||
LL | } else { | ||
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 ~ let x = 'block: { | ||
LL | if n == 0 { | ||
LL ~ break 'block 1; | ||
LL | } else { | ||
LL ~ break 'block 2; | ||
| | ||
|
||
error[E0268]: `break` outside of a loop or labeled block | ||
--> $DIR/loop-if-else-break-issue-123261.rs:18:13 | ||
| | ||
LL | break 1; | ||
| ^^^^^^^ cannot `break` outside of a loop or labeled block | ||
LL | } | ||
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 ~ let y = 'block: { | ||
LL | if n == 0 { | ||
LL ~ break 'block 1; | ||
LL | } | ||
LL ~ break 'block 0; | ||
| | ||
|
||
error[E0268]: `break` outside of a loop or labeled block | ||
--> $DIR/loop-if-else-break-issue-123261.rs:26:17 | ||
| | ||
LL | break 3; | ||
| ^^^^^^^ cannot `break` outside of a loop or labeled block | ||
... | ||
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 z = 'block: { | ||
LL | if n == 0 { | ||
LL | if m > 1 { | ||
LL ~ break 'block 3; | ||
LL | } | ||
LL | } | ||
LL ~ break 'block 1; | ||
| | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0268`. |
Oops, something went wrong.