Skip to content

Commit 5da32ab

Browse files
committed
Auto merge of #123792 - oli-obk:coroutine_closures, r=compiler-errors
Require explicitly marking closures as coroutines instead of relying on patching up the closure to be a coroutine if it happens to contain a `yield` expression. I only do this in the 2024 edition, as the `gen` keyword is only available there.
2 parents 34343b3 + 24108e0 commit 5da32ab

File tree

5 files changed

+13
-15
lines changed

5 files changed

+13
-15
lines changed

tests/ui/crashes/ice-5238.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Regression test for #5238 / https://github.com/rust-lang/rust/pull/69562
22

3-
#![feature(coroutines, coroutine_trait)]
3+
#![feature(coroutines, coroutine_trait, stmt_expr_attributes)]
44

55
fn main() {
6-
let _ = || {
6+
let _ = #[coroutine] || {
77
yield;
88
};
99
}

tests/ui/large_futures.fixed

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(coroutines)]
21
#![warn(clippy::large_futures)]
32
#![allow(clippy::never_loop)]
43
#![allow(clippy::future_not_send)]

tests/ui/large_futures.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(coroutines)]
21
#![warn(clippy::large_futures)]
32
#![allow(clippy::never_loop)]
43
#![allow(clippy::future_not_send)]

tests/ui/large_futures.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: large future with a size of 16385 bytes
2-
--> tests/ui/large_futures.rs:11:9
2+
--> tests/ui/large_futures.rs:10:9
33
|
44
LL | big_fut([0u8; 1024 * 16]).await;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Box::pin` on it: `Box::pin(big_fut([0u8; 1024 * 16]))`
@@ -8,37 +8,37 @@ LL | big_fut([0u8; 1024 * 16]).await;
88
= help: to override `-D warnings` add `#[allow(clippy::large_futures)]`
99

1010
error: large future with a size of 16386 bytes
11-
--> tests/ui/large_futures.rs:15:5
11+
--> tests/ui/large_futures.rs:14:5
1212
|
1313
LL | f.await
1414
| ^ help: consider `Box::pin` on it: `Box::pin(f)`
1515

1616
error: large future with a size of 16387 bytes
17-
--> tests/ui/large_futures.rs:20:9
17+
--> tests/ui/large_futures.rs:19:9
1818
|
1919
LL | wait().await;
2020
| ^^^^^^ help: consider `Box::pin` on it: `Box::pin(wait())`
2121

2222
error: large future with a size of 16387 bytes
23-
--> tests/ui/large_futures.rs:25:13
23+
--> tests/ui/large_futures.rs:24:13
2424
|
2525
LL | wait().await;
2626
| ^^^^^^ help: consider `Box::pin` on it: `Box::pin(wait())`
2727

2828
error: large future with a size of 65540 bytes
29-
--> tests/ui/large_futures.rs:33:5
29+
--> tests/ui/large_futures.rs:32:5
3030
|
3131
LL | foo().await;
3232
| ^^^^^ help: consider `Box::pin` on it: `Box::pin(foo())`
3333

3434
error: large future with a size of 49159 bytes
35-
--> tests/ui/large_futures.rs:35:5
35+
--> tests/ui/large_futures.rs:34:5
3636
|
3737
LL | calls_fut(fut).await;
3838
| ^^^^^^^^^^^^^^ help: consider `Box::pin` on it: `Box::pin(calls_fut(fut))`
3939

4040
error: large future with a size of 65540 bytes
41-
--> tests/ui/large_futures.rs:48:5
41+
--> tests/ui/large_futures.rs:47:5
4242
|
4343
LL | / async {
4444
LL | |
@@ -59,7 +59,7 @@ LL + })
5959
|
6060

6161
error: large future with a size of 65540 bytes
62-
--> tests/ui/large_futures.rs:60:13
62+
--> tests/ui/large_futures.rs:59:13
6363
|
6464
LL | / async {
6565
LL | | let x = [0i32; 1024 * 16];

tests/ui/redundant_locals.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@aux-build:proc_macros.rs
22
#![allow(unused, clippy::no_effect, clippy::needless_pass_by_ref_mut)]
33
#![warn(clippy::redundant_locals)]
4-
#![feature(async_closure, coroutines)]
4+
#![feature(async_closure, coroutines, stmt_expr_attributes)]
55

66
extern crate proc_macros;
77
use proc_macros::{external, with_span};
@@ -191,11 +191,11 @@ fn issue12225() {
191191
let v4 = v4;
192192
dbg!(&v4);
193193
});
194-
assert_static(static || {
194+
assert_static(#[coroutine] static || {
195195
let v5 = v5;
196196
yield;
197197
});
198-
assert_static(|| {
198+
assert_static(#[coroutine] || {
199199
let v6 = v6;
200200
yield;
201201
});

0 commit comments

Comments
 (0)