Skip to content

Commit 764675e

Browse files
Add Tests
1 parent 64ebd39 commit 764675e

4 files changed

+114
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
fn main() {
2+
let _ = ['a'; { break 2; 1 }];
3+
//~^ ERROR `break` outside of a loop or labeled block
4+
//~| HELP consider labeling this block to be able to break within it
5+
6+
const {
7+
{
8+
//~^ HELP consider labeling this block to be able to break within it
9+
break;
10+
//~^ ERROR `break` outside of a loop or labeled block
11+
}
12+
};
13+
14+
const {
15+
break;
16+
//~^ ERROR `break` outside of a loop or labeled block
17+
};
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
error[E0268]: `break` outside of a loop or labeled block
2+
--> $DIR/break-inside-inline-const-issue-128604.rs:2:21
3+
|
4+
LL | let _ = ['a'; { break 2; 1 }];
5+
| ^^^^^^^ cannot `break` outside of a loop or labeled block
6+
|
7+
help: consider labeling this block to be able to break within it
8+
|
9+
LL | let _ = ['a'; 'block: { break 'block 2; 1 }];
10+
| +++++++ ++++++
11+
12+
error[E0268]: `break` outside of a loop or labeled block
13+
--> $DIR/break-inside-inline-const-issue-128604.rs:9:13
14+
|
15+
LL | break;
16+
| ^^^^^ cannot `break` outside of a loop or labeled block
17+
|
18+
help: consider labeling this block to be able to break within it
19+
|
20+
LL ~ 'block: {
21+
LL |
22+
LL ~ break 'block;
23+
|
24+
25+
error[E0268]: `break` outside of a loop or labeled block
26+
--> $DIR/break-inside-inline-const-issue-128604.rs:15:9
27+
|
28+
LL | break;
29+
| ^^^^^ cannot `break` outside of a loop or labeled block
30+
|
31+
help: consider labeling this block to be able to break within it
32+
|
33+
LL ~ const 'block: {
34+
LL ~ break 'block;
35+
|
36+
37+
error: aborting due to 3 previous errors
38+
39+
For more information about this error, try `rustc --explain E0268`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
fn main() {
2+
let a = ["_"; unsafe { break; 1 + 2 }];
3+
//~^ ERROR `break` outside of a loop or labeled block
4+
5+
unsafe {
6+
{
7+
//~^ HELP consider labeling this block to be able to break within it
8+
break;
9+
//~^ ERROR `break` outside of a loop or labeled block
10+
}
11+
}
12+
13+
unsafe {
14+
break;
15+
//~^ ERROR `break` outside of a loop or labeled block
16+
}
17+
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
error[E0268]: `break` outside of a loop or labeled block
2+
--> $DIR/break-inside-unsafe-block-issue-128604.rs:2:28
3+
|
4+
LL | let a = ["_"; unsafe { break; 1 + 2 }];
5+
| ^^^^^ cannot `break` outside of a loop or labeled block
6+
|
7+
help: consider labeling this block to be able to break within it
8+
|
9+
LL | let a = ["_"; 'block: unsafe { break 'block; 1 + 2 }];
10+
| +++++++ ++++++
11+
12+
error[E0268]: `break` outside of a loop or labeled block
13+
--> $DIR/break-inside-unsafe-block-issue-128604.rs:8:13
14+
|
15+
LL | break;
16+
| ^^^^^ cannot `break` outside of a loop or labeled block
17+
|
18+
help: consider labeling this block to be able to break within it
19+
|
20+
LL ~ 'block: {
21+
LL |
22+
LL ~ break 'block;
23+
|
24+
25+
error[E0268]: `break` outside of a loop or labeled block
26+
--> $DIR/break-inside-unsafe-block-issue-128604.rs:14:9
27+
|
28+
LL | break;
29+
| ^^^^^ cannot `break` outside of a loop or labeled block
30+
|
31+
help: consider labeling this block to be able to break within it
32+
|
33+
LL ~ 'block: unsafe {
34+
LL ~ break 'block;
35+
|
36+
37+
error: aborting due to 3 previous errors
38+
39+
For more information about this error, try `rustc --explain E0268`.

0 commit comments

Comments
 (0)