You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rollup merge of rust-lang#125392 - workingjubilee:unwind-a-problem-in-context, r=Amanieu
Wrap Context.ext in AssertUnwindSafe
Fixesrust-lang#125193
Alternative to rust-lang#125377
Relevant to rust-lang#123392
I believe this approach is justifiable due to the fact that this function is unstable API and we have been considering trying to dispose of the notion of "unwind safety". Making a more long-term decision should be considered carefully as part of stabilizing `fn ext`, if ever.
r? `@Amanieu`
Copy file name to clipboardexpand all lines: tests/ui/async-await/async-is-unwindsafe.stderr
+6-37
Original file line number
Diff line number
Diff line change
@@ -6,18 +6,19 @@ LL | is_unwindsafe(async {
6
6
| |_____|
7
7
| ||
8
8
LL | ||
9
-
LL | ||
10
9
LL | || use std::ptr::null;
10
+
LL | || use std::task::{Context, RawWaker, RawWakerVTable, Waker};
11
11
... ||
12
12
LL | || drop(cx_ref);
13
13
LL | || });
14
14
| ||_____-^ `&mut Context<'_>` may not be safely transferred across an unwind boundary
15
15
| |_____|
16
-
| within this `{async block@$DIR/async-is-unwindsafe.rs:12:19: 30:6}`
16
+
| within this `{async block@$DIR/async-is-unwindsafe.rs:12:19: 29:6}`
17
17
|
18
-
= help: within `{async block@$DIR/async-is-unwindsafe.rs:12:19: 30:6}`, the trait `UnwindSafe` is not implemented for `&mut Context<'_>`, which is required by `{async block@$DIR/async-is-unwindsafe.rs:12:19: 30:6}: UnwindSafe`
18
+
= help: within `{async block@$DIR/async-is-unwindsafe.rs:12:19: 29:6}`, the trait `UnwindSafe` is not implemented for `&mut Context<'_>`, which is required by `{async block@$DIR/async-is-unwindsafe.rs:12:19: 29:6}: UnwindSafe`
19
+
= note: `UnwindSafe` is implemented for `&Context<'_>`, but not for `&mut Context<'_>`
19
20
note: future does not implement `UnwindSafe` as this value is used across an await
20
-
--> $DIR/async-is-unwindsafe.rs:26:18
21
+
--> $DIR/async-is-unwindsafe.rs:25:18
21
22
|
22
23
LL | let cx_ref = &mut cx;
23
24
| ------ has type `&mut Context<'_>` which does not implement `UnwindSafe`
@@ -30,38 +31,6 @@ note: required by a bound in `is_unwindsafe`
| ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_unwindsafe`
32
33
33
-
error[E0277]: the type `&mut (dyn Any + 'static)` may not be safely transferred across an unwind boundary
34
-
--> $DIR/async-is-unwindsafe.rs:12:5
35
-
|
36
-
LL | is_unwindsafe(async {
37
-
| _____^_____________-
38
-
| |_____|
39
-
| ||
40
-
LL | ||
41
-
LL | ||
42
-
LL | || use std::ptr::null;
43
-
... ||
44
-
LL | || drop(cx_ref);
45
-
LL | || });
46
-
| ||_____-^ `&mut (dyn Any + 'static)` may not be safely transferred across an unwind boundary
47
-
| |_____|
48
-
| within this `{async block@$DIR/async-is-unwindsafe.rs:12:19: 30:6}`
49
-
|
50
-
= help: within `{async block@$DIR/async-is-unwindsafe.rs:12:19: 30:6}`, the trait `UnwindSafe` is not implemented for `&mut (dyn Any + 'static)`, which is required by `{async block@$DIR/async-is-unwindsafe.rs:12:19: 30:6}: UnwindSafe`
51
-
note: future does not implement `UnwindSafe` as this value is used across an await
52
-
--> $DIR/async-is-unwindsafe.rs:26:18
53
-
|
54
-
LL | let mut cx = Context::from_waker(&waker);
55
-
| ------ has type `Context<'_>` which does not implement `UnwindSafe`
56
-
...
57
-
LL | async {}.await; // this needs an inner await point
58
-
| ^^^^^ await occurs here, with `mut cx` maybe used later
0 commit comments