Skip to content

Commit 833bbcc

Browse files
Update Tests and Error Code Doc
1 parent 9c9b568 commit 833bbcc

12 files changed

+119
-24
lines changed

compiler/rustc_error_codes/src/error_codes/E0267.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ any loop.
44
Erroneous code example:
55

66
```compile_fail,E0267
7-
let w = || { break; }; // error: `break` inside of a closure
7+
let w = || { break; }; // error: `break` inside a closure
88
```
99

1010
`break` and `continue` keywords can be used as normal inside closures as long as

tests/ui/async-await/async-block-control-flow-static-semantics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ async fn return_targets_async_block_not_async_fn() -> u8 {
2929

3030
fn no_break_in_async_block() {
3131
async {
32-
break 0u8; //~ ERROR `break` inside of an `async` block
32+
break 0u8; //~ ERROR `break` inside an `async` block
3333
};
3434
}
3535

3636
fn no_break_in_async_block_even_with_outer_loop() {
3737
loop {
3838
async {
39-
break 0u8; //~ ERROR `break` inside of an `async` block
39+
break 0u8; //~ ERROR `break` inside an `async` block
4040
};
4141
}
4242
}

tests/ui/async-await/async-block-control-flow-static-semantics.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
error[E0267]: `break` inside of an `async` block
1+
error[E0267]: `break` inside an `async` block
22
--> $DIR/async-block-control-flow-static-semantics.rs:32:9
33
|
44
LL | / async {
55
LL | | break 0u8;
6-
| | ^^^^^^^^^ cannot `break` inside of an `async` block
6+
| | ^^^^^^^^^ cannot `break` inside an `async` block
77
LL | | };
88
| |_____- enclosing `async` block
99

10-
error[E0267]: `break` inside of an `async` block
10+
error[E0267]: `break` inside an `async` block
1111
--> $DIR/async-block-control-flow-static-semantics.rs:39:13
1212
|
1313
LL | / async {
1414
LL | | break 0u8;
15-
| | ^^^^^^^^^ cannot `break` inside of an `async` block
15+
| | ^^^^^^^^^ cannot `break` inside an `async` block
1616
LL | | };
1717
| |_________- enclosing `async` block
1818

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//@ edition: 2024
2+
//@ compile-flags: -Z unstable-options
3+
4+
#![feature(gen_blocks)]
5+
#![feature(async_closure)]
6+
7+
async fn async_fn() {
8+
break; //~ ERROR `break` inside an `async` function
9+
}
10+
11+
gen fn gen_fn() {
12+
break; //~ ERROR `break` inside a `gen` function
13+
}
14+
15+
async gen fn async_gen_fn() {
16+
break; //~ ERROR `break` inside an `async gen` function
17+
}
18+
19+
fn main() {
20+
let _ = async { break; }; //~ ERROR `break` inside an `async` block
21+
let _ = async || { break; }; //~ ERROR `break` inside an `async` closure
22+
23+
let _ = gen { break; }; //~ ERROR `break` inside a `gen` block
24+
25+
let _ = async gen { break; }; //~ ERROR `break` inside an `async gen` block
26+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
error[E0267]: `break` inside an `async` function
2+
--> $DIR/break-inside-coroutine-issue-124495.rs:8:5
3+
|
4+
LL | async fn async_fn() {
5+
| _____________________-
6+
LL | | break;
7+
| | ^^^^^ cannot `break` inside an `async` function
8+
LL | | }
9+
| |_- enclosing `async` function
10+
11+
error[E0267]: `break` inside a `gen` function
12+
--> $DIR/break-inside-coroutine-issue-124495.rs:12:5
13+
|
14+
LL | gen fn gen_fn() {
15+
| _________________-
16+
LL | | break;
17+
| | ^^^^^ cannot `break` inside a `gen` function
18+
LL | | }
19+
| |_- enclosing `gen` function
20+
21+
error[E0267]: `break` inside an `async gen` function
22+
--> $DIR/break-inside-coroutine-issue-124495.rs:16:5
23+
|
24+
LL | async gen fn async_gen_fn() {
25+
| _____________________________-
26+
LL | | break;
27+
| | ^^^^^ cannot `break` inside an `async gen` function
28+
LL | | }
29+
| |_- enclosing `async gen` function
30+
31+
error[E0267]: `break` inside an `async` block
32+
--> $DIR/break-inside-coroutine-issue-124495.rs:20:21
33+
|
34+
LL | let _ = async { break; };
35+
| --------^^^^^---
36+
| | |
37+
| | cannot `break` inside an `async` block
38+
| enclosing `async` block
39+
40+
error[E0267]: `break` inside an `async` closure
41+
--> $DIR/break-inside-coroutine-issue-124495.rs:21:24
42+
|
43+
LL | let _ = async || { break; };
44+
| --^^^^^---
45+
| | |
46+
| | cannot `break` inside an `async` closure
47+
| enclosing `async` closure
48+
49+
error[E0267]: `break` inside a `gen` block
50+
--> $DIR/break-inside-coroutine-issue-124495.rs:23:19
51+
|
52+
LL | let _ = gen { break; };
53+
| ------^^^^^---
54+
| | |
55+
| | cannot `break` inside a `gen` block
56+
| enclosing `gen` block
57+
58+
error[E0267]: `break` inside an `async gen` block
59+
--> $DIR/break-inside-coroutine-issue-124495.rs:25:25
60+
|
61+
LL | let _ = async gen { break; };
62+
| ------------^^^^^---
63+
| | |
64+
| | cannot `break` inside an `async gen` block
65+
| enclosing `async gen` block
66+
67+
error: aborting due to 7 previous errors
68+
69+
For more information about this error, try `rustc --explain E0267`.

tests/ui/error-codes/E0267.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0267]: `break` inside of a closure
1+
error[E0267]: `break` inside a closure
22
--> $DIR/E0267.rs:2:18
33
|
44
LL | let w = || { break; };
5-
| -- ^^^^^ cannot `break` inside of a closure
5+
| -- ^^^^^ cannot `break` inside a closure
66
| |
77
| enclosing closure
88

tests/ui/for-loop-while/break-outside-loop.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ fn main() {
1414
if cond() { break }
1515
if cond() { continue }
1616
foo(|| {
17-
if cond() { break } //~ ERROR: `break` inside of a closure
18-
if cond() { continue } //~ ERROR: `continue` inside of a closure
17+
if cond() { break } //~ ERROR: `break` inside a closure
18+
if cond() { continue } //~ ERROR: `continue` inside a closure
1919
})
2020
}
2121

@@ -29,7 +29,7 @@ fn main() {
2929
|| {
3030
break 'lab;
3131
//~^ ERROR use of unreachable label `'lab`
32-
//~| ERROR `break` inside of a closure
32+
//~| ERROR `break` inside a closure
3333
};
3434
}
3535
}

tests/ui/for-loop-while/break-outside-loop.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,36 @@ error[E0268]: `continue` outside of a loop
2121
LL | if cond() { continue }
2222
| ^^^^^^^^ cannot `continue` outside of a loop
2323

24-
error[E0267]: `break` inside of a closure
24+
error[E0267]: `break` inside a closure
2525
--> $DIR/break-outside-loop.rs:17:25
2626
|
2727
LL | foo(|| {
2828
| -- enclosing closure
2929
LL | if cond() { break }
30-
| ^^^^^ cannot `break` inside of a closure
30+
| ^^^^^ cannot `break` inside a closure
3131

32-
error[E0267]: `continue` inside of a closure
32+
error[E0267]: `continue` inside a closure
3333
--> $DIR/break-outside-loop.rs:18:25
3434
|
3535
LL | foo(|| {
3636
| -- enclosing closure
3737
LL | if cond() { break }
3838
LL | if cond() { continue }
39-
| ^^^^^^^^ cannot `continue` inside of a closure
39+
| ^^^^^^^^ cannot `continue` inside a closure
4040

4141
error[E0268]: `break` outside of a loop or labeled block
4242
--> $DIR/break-outside-loop.rs:24:25
4343
|
4444
LL | let unconstrained = break;
4545
| ^^^^^ cannot `break` outside of a loop or labeled block
4646

47-
error[E0267]: `break` inside of a closure
47+
error[E0267]: `break` inside a closure
4848
--> $DIR/break-outside-loop.rs:30:13
4949
|
5050
LL | || {
5151
| -- enclosing closure
5252
LL | break 'lab;
53-
| ^^^^^^^^^^ cannot `break` inside of a closure
53+
| ^^^^^^^^^^ cannot `break` inside a closure
5454

5555
error: aborting due to 7 previous errors
5656

tests/ui/issues/issue-62480.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ fn main() {
55
'a: {
66
|| break 'a
77
//~^ ERROR use of unreachable label `'a`
8-
//~| ERROR `break` inside of a closure
8+
//~| ERROR `break` inside a closure
99
}
1010
}

tests/ui/issues/issue-62480.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ LL | || break 'a
88
|
99
= note: labels are unreachable through functions, closures, async blocks and modules
1010

11-
error[E0267]: `break` inside of a closure
11+
error[E0267]: `break` inside a closure
1212
--> $DIR/issue-62480.rs:6:12
1313
|
1414
LL | || break 'a
15-
| -- ^^^^^^^^ cannot `break` inside of a closure
15+
| -- ^^^^^^^^ cannot `break` inside a closure
1616
| |
1717
| enclosing closure
1818

tests/ui/issues/issue-66702-break-outside-loop-val.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ fn main() {
44
'some_label: loop {
55
|| break 'some_label ();
66
//~^ ERROR: use of unreachable label `'some_label`
7-
//~| ERROR: `break` inside of a closure
7+
//~| ERROR: `break` inside a closure
88
}
99
}

tests/ui/issues/issue-66702-break-outside-loop-val.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ LL | || break 'some_label ();
88
|
99
= note: labels are unreachable through functions, closures, async blocks and modules
1010

11-
error[E0267]: `break` inside of a closure
11+
error[E0267]: `break` inside a closure
1212
--> $DIR/issue-66702-break-outside-loop-val.rs:5:12
1313
|
1414
LL | || break 'some_label ();
15-
| -- ^^^^^^^^^^^^^^^^^^^^ cannot `break` inside of a closure
15+
| -- ^^^^^^^^^^^^^^^^^^^^ cannot `break` inside a closure
1616
| |
1717
| enclosing closure
1818

0 commit comments

Comments
 (0)