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 #127058 - compiler-errors:tighten-async-spans, r=oli-obk
Tighten `fn_decl_span` for async blocks
Tightens the span of `async {}` blocks in diagnostics, and subsequently async closures and async fns, by actually setting the `fn_decl_span` correctly. This is kinda a follow-up on #125078, but it fixes the problem in a more general way.
I think the diagnostics are significantly improved, since we no longer have a bunch of overlapping spans. I'll point out one caveat where I think the diagnostic may get a bit more confusing, but where I don't think it matters.
r? ```@estebank``` or ```@oli-obk``` or someone else on wg-diag or compiler i dont really care lol
error[E0271]: expected `{async block@$DIR/async-block-control-flow-static-semantics.rs:23:17: 25:6}` to be a future that resolves to `()`, but it resolves to `u8`
30
+
error[E0271]: expected `{async block@$DIR/async-block-control-flow-static-semantics.rs:23:17: 23:22}` to be a future that resolves to `()`, but it resolves to `u8`
| implicitly returns `()` as its body has no tail or `return` expression
47
45
48
-
error[E0271]: expected `{async block@$DIR/async-block-control-flow-static-semantics.rs:14:17: 16:6}` to be a future that resolves to `()`, but it resolves to `u8`
46
+
error[E0271]: expected `{async block@$DIR/async-block-control-flow-static-semantics.rs:14:17: 14:22}` to be a future that resolves to `()`, but it resolves to `u8`
Copy file name to clipboardexpand all lines: tests/ui/async-await/async-is-unwindsafe.stderr
+12-13
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,19 @@
1
1
error[E0277]: the type `&mut Context<'_>` may not be safely transferred across an unwind boundary
2
2
--> $DIR/async-is-unwindsafe.rs:12:5
3
3
|
4
-
LL | is_unwindsafe(async {
5
-
| ______^ -
6
-
| | ___________________|
7
-
LL | ||
8
-
LL | || use std::ptr::null;
9
-
LL | || use std::task::{Context, RawWaker, RawWakerVTable, Waker};
10
-
... ||
11
-
LL | || drop(cx_ref);
12
-
LL | || });
13
-
| ||_____-^ `&mut Context<'_>` may not be safely transferred across an unwind boundary
14
-
| |_____|
15
-
| within this `{async block@$DIR/async-is-unwindsafe.rs:12:19: 29:6}`
4
+
LL | is_unwindsafe(async {
5
+
| ^ ----- within this `{async block@$DIR/async-is-unwindsafe.rs:12:19: 12:24}`
6
+
| _____|
7
+
| |
8
+
LL | |
9
+
LL | | use std::ptr::null;
10
+
LL | | use std::task::{Context, RawWaker, RawWakerVTable, Waker};
11
+
... |
12
+
LL | | drop(cx_ref);
13
+
LL | | });
14
+
| |______^ `&mut Context<'_>` may not be safely transferred across an unwind boundary
16
15
|
17
-
= 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`
16
+
= help: within `{async block@$DIR/async-is-unwindsafe.rs:12:19: 12:24}`, the trait `UnwindSafe` is not implemented for `&mut Context<'_>`, which is required by `{async block@$DIR/async-is-unwindsafe.rs:12:19: 12:24}: UnwindSafe`
18
17
= note: `UnwindSafe` is implemented for `&Context<'_>`, but not for `&mut Context<'_>`
19
18
note: future does not implement `UnwindSafe` as this value is used across an await
0 commit comments