Skip to content

Commit 65519f5

Browse files
committed
Auto merge of #116360 - compiler-errors:async-span, r=oli-obk
Point to full `async fn` for future Semi-follow-up to #116296 (comment) cc `@asquared31415`
2 parents 9fbd593 + 2934fe0 commit 65519f5

18 files changed

+68
-64
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,7 +1824,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
18241824
}
18251825

18261826
let fn_def_id = self.local_def_id(fn_node_id);
1827-
self.lower_async_fn_ret_ty(&decl.output, fn_def_id, ret_id, kind)
1827+
self.lower_async_fn_ret_ty(&decl.output, fn_def_id, ret_id, kind, fn_span)
18281828
} else {
18291829
match &decl.output {
18301830
FnRetTy::Ty(ty) => {
@@ -1901,8 +1901,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19011901
fn_def_id: LocalDefId,
19021902
opaque_ty_node_id: NodeId,
19031903
fn_kind: FnDeclKind,
1904+
fn_span: Span,
19041905
) -> hir::FnRetTy<'hir> {
1905-
let span = self.lower_span(output.span());
1906+
let span = self.lower_span(fn_span);
19061907
let opaque_ty_span = self.mark_span_with_reason(DesugaringKind::Async, span, None);
19071908

19081909
let captured_lifetimes: Vec<_> = self

src/tools/clippy/tests/ui/crashes/ice-10645.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
warning: future cannot be sent between threads safely
2-
--> $DIR/ice-10645.rs:5:35
2+
--> $DIR/ice-10645.rs:5:1
33
|
44
LL | pub async fn bar<'a, T: 'a>(_: T) {}
5-
| ^ future returned by `bar` is not `Send`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `bar` is not `Send`
66
|
77
note: captured value is not `Send`
88
--> $DIR/ice-10645.rs:5:29

src/tools/clippy/tests/ui/future_not_send.stderr

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: future cannot be sent between threads safely
2-
--> $DIR/future_not_send.rs:7:62
2+
--> $DIR/future_not_send.rs:7:1
33
|
44
LL | async fn private_future(rc: Rc<[u8]>, cell: &Cell<usize>) -> bool {
5-
| ^^^^ future returned by `private_future` is not `Send`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `private_future` is not `Send`
66
|
77
note: future is not `Send` as this value is used across an await
88
--> $DIR/future_not_send.rs:9:20
@@ -23,10 +23,10 @@ LL | async fn private_future(rc: Rc<[u8]>, cell: &Cell<usize>) -> bool {
2323
= help: to override `-D warnings` add `#[allow(clippy::future_not_send)]`
2424

2525
error: future cannot be sent between threads safely
26-
--> $DIR/future_not_send.rs:12:42
26+
--> $DIR/future_not_send.rs:12:1
2727
|
2828
LL | pub async fn public_future(rc: Rc<[u8]>) {
29-
| ^ future returned by `public_future` is not `Send`
29+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `public_future` is not `Send`
3030
|
3131
note: future is not `Send` as this value is used across an await
3232
--> $DIR/future_not_send.rs:14:20
@@ -39,10 +39,10 @@ LL | async { true }.await;
3939
= note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Send`
4040

4141
error: future cannot be sent between threads safely
42-
--> $DIR/future_not_send.rs:21:63
42+
--> $DIR/future_not_send.rs:21:1
4343
|
4444
LL | async fn private_future2(rc: Rc<[u8]>, cell: &Cell<usize>) -> bool {
45-
| ^^^^ future returned by `private_future2` is not `Send`
45+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `private_future2` is not `Send`
4646
|
4747
note: captured value is not `Send`
4848
--> $DIR/future_not_send.rs:21:26
@@ -58,10 +58,10 @@ LL | async fn private_future2(rc: Rc<[u8]>, cell: &Cell<usize>) -> bool {
5858
= note: `std::cell::Cell<usize>` doesn't implement `std::marker::Sync`
5959

6060
error: future cannot be sent between threads safely
61-
--> $DIR/future_not_send.rs:26:43
61+
--> $DIR/future_not_send.rs:26:1
6262
|
6363
LL | pub async fn public_future2(rc: Rc<[u8]>) {}
64-
| ^ future returned by `public_future2` is not `Send`
64+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `public_future2` is not `Send`
6565
|
6666
note: captured value is not `Send`
6767
--> $DIR/future_not_send.rs:26:29
@@ -71,10 +71,10 @@ LL | pub async fn public_future2(rc: Rc<[u8]>) {}
7171
= note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Send`
7272

7373
error: future cannot be sent between threads safely
74-
--> $DIR/future_not_send.rs:38:39
74+
--> $DIR/future_not_send.rs:38:5
7575
|
7676
LL | async fn private_future(&self) -> usize {
77-
| ^^^^^ future returned by `private_future` is not `Send`
77+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `private_future` is not `Send`
7878
|
7979
note: future is not `Send` as this value is used across an await
8080
--> $DIR/future_not_send.rs:40:24
@@ -87,10 +87,10 @@ LL | async { true }.await;
8787
= note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Sync`
8888

8989
error: future cannot be sent between threads safely
90-
--> $DIR/future_not_send.rs:44:39
90+
--> $DIR/future_not_send.rs:44:5
9191
|
9292
LL | pub async fn public_future(&self) {
93-
| ^ future returned by `public_future` is not `Send`
93+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `public_future` is not `Send`
9494
|
9595
note: captured value is not `Send` because `&` references cannot be sent unless their referent is `Sync`
9696
--> $DIR/future_not_send.rs:44:32
@@ -100,10 +100,13 @@ LL | pub async fn public_future(&self) {
100100
= note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Sync`
101101

102102
error: future cannot be sent between threads safely
103-
--> $DIR/future_not_send.rs:55:37
103+
--> $DIR/future_not_send.rs:55:1
104104
|
105-
LL | async fn generic_future<T>(t: T) -> T
106-
| ^ future returned by `generic_future` is not `Send`
105+
LL | / async fn generic_future<T>(t: T) -> T
106+
LL | |
107+
LL | | where
108+
LL | | T: Send,
109+
| |____________^ future returned by `generic_future` is not `Send`
107110
|
108111
note: future is not `Send` as this value is used across an await
109112
--> $DIR/future_not_send.rs:61:20
@@ -115,10 +118,10 @@ LL | async { true }.await;
115118
= note: `T` doesn't implement `std::marker::Sync`
116119

117120
error: future cannot be sent between threads safely
118-
--> $DIR/future_not_send.rs:73:34
121+
--> $DIR/future_not_send.rs:73:1
119122
|
120123
LL | async fn unclear_future<T>(t: T) {}
121-
| ^ future returned by `unclear_future` is not `Send`
124+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `unclear_future` is not `Send`
122125
|
123126
note: captured value is not `Send`
124127
--> $DIR/future_not_send.rs:73:28

tests/ui/async-await/async-await-let-else.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ error[E0277]: `Rc<()>` cannot be sent between threads safely
2222
--> $DIR/async-await-let-else.rs:47:13
2323
|
2424
LL | async fn foo2(x: Option<bool>) {
25-
| - within this `impl Future<Output = ()>`
25+
| ------------------------------ within this `impl Future<Output = ()>`
2626
...
2727
LL | is_send(foo2(Some(true)));
2828
| ------- ^^^^^^^^^^^^^^^^ `Rc<()>` cannot be sent between threads safely

tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0053]: method `foo` has an incompatible type for trait
2-
--> $DIR/async-example-desugared-boxed-in-trait.rs:15:28
2+
--> $DIR/async-example-desugared-boxed-in-trait.rs:15:5
33
|
44
LL | async fn foo(&self) -> i32 {
5-
| ^^^ expected `Pin<Box<dyn Future<Output = i32>>>`, found future
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Pin<Box<dyn Future<Output = i32>>>`, found future
66
|
77
note: type in trait
88
--> $DIR/async-example-desugared-boxed-in-trait.rs:11:22

tests/ui/async-await/in-trait/async-generics-and-bounds.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
error[E0311]: the parameter type `U` may not live long enough
2-
--> $DIR/async-generics-and-bounds.rs:12:28
2+
--> $DIR/async-generics-and-bounds.rs:12:5
33
|
44
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
5-
| ^^^^^^^
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
note: the parameter type `U` must be valid for the anonymous lifetime as defined here...
88
--> $DIR/async-generics-and-bounds.rs:12:18
99
|
1010
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
1111
| ^
1212
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
13-
--> $DIR/async-generics-and-bounds.rs:12:28
13+
--> $DIR/async-generics-and-bounds.rs:12:5
1414
|
1515
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
16-
| ^^^^^^^
16+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1717

1818
error[E0311]: the parameter type `T` may not live long enough
19-
--> $DIR/async-generics-and-bounds.rs:12:28
19+
--> $DIR/async-generics-and-bounds.rs:12:5
2020
|
2121
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
22-
| ^^^^^^^
22+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2323
|
2424
note: the parameter type `T` must be valid for the anonymous lifetime as defined here...
2525
--> $DIR/async-generics-and-bounds.rs:12:18
2626
|
2727
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
2828
| ^
2929
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
30-
--> $DIR/async-generics-and-bounds.rs:12:28
30+
--> $DIR/async-generics-and-bounds.rs:12:5
3131
|
3232
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
33-
| ^^^^^^^
33+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3434

3535
error: aborting due to 2 previous errors
3636

tests/ui/async-await/in-trait/async-generics.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
error[E0311]: the parameter type `U` may not live long enough
2-
--> $DIR/async-generics.rs:9:28
2+
--> $DIR/async-generics.rs:9:5
33
|
44
LL | async fn foo(&self) -> &(T, U);
5-
| ^^^^^^^
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
note: the parameter type `U` must be valid for the anonymous lifetime as defined here...
88
--> $DIR/async-generics.rs:9:18
99
|
1010
LL | async fn foo(&self) -> &(T, U);
1111
| ^
1212
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
13-
--> $DIR/async-generics.rs:9:28
13+
--> $DIR/async-generics.rs:9:5
1414
|
1515
LL | async fn foo(&self) -> &(T, U);
16-
| ^^^^^^^
16+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1717

1818
error[E0311]: the parameter type `T` may not live long enough
19-
--> $DIR/async-generics.rs:9:28
19+
--> $DIR/async-generics.rs:9:5
2020
|
2121
LL | async fn foo(&self) -> &(T, U);
22-
| ^^^^^^^
22+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2323
|
2424
note: the parameter type `T` must be valid for the anonymous lifetime as defined here...
2525
--> $DIR/async-generics.rs:9:18
2626
|
2727
LL | async fn foo(&self) -> &(T, U);
2828
| ^
2929
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
30-
--> $DIR/async-generics.rs:9:28
30+
--> $DIR/async-generics.rs:9:5
3131
|
3232
LL | async fn foo(&self) -> &(T, U);
33-
| ^^^^^^^
33+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3434

3535
error: aborting due to 2 previous errors
3636

tests/ui/async-await/in-trait/async-recursive-generic.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0733]: recursion in an `async fn` requires boxing
2-
--> $DIR/async-recursive-generic.rs:11:48
2+
--> $DIR/async-recursive-generic.rs:11:5
33
|
44
LL | async fn foo_recursive(&self, n: usize) -> T {
5-
| ^ recursive `async fn`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ recursive `async fn`
66
|
77
= note: a recursive `async fn` must be rewritten to return a boxed `dyn Future`
88
= note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion

tests/ui/async-await/in-trait/async-recursive.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0733]: recursion in an `async fn` requires boxing
2-
--> $DIR/async-recursive.rs:11:48
2+
--> $DIR/async-recursive.rs:11:5
33
|
44
LL | async fn foo_recursive(&self, n: usize) -> i32 {
5-
| ^^^ recursive `async fn`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ recursive `async fn`
66
|
77
= note: a recursive `async fn` must be rewritten to return a boxed `dyn Future`
88
= note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion

tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
error[E0053]: method `foo` has an incompatible type for trait
2-
--> $DIR/dont-project-to-specializable-projection.rs:14:35
2+
--> $DIR/dont-project-to-specializable-projection.rs:14:5
33
|
44
LL | default async fn foo(_: T) -> &'static str {
5-
| ^^^^^^^^^^^^ expected associated type, found future
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected associated type, found future
66
|
77
note: type in trait
8-
--> $DIR/dont-project-to-specializable-projection.rs:10:27
8+
--> $DIR/dont-project-to-specializable-projection.rs:10:5
99
|
1010
LL | async fn foo(_: T) -> &'static str;
11-
| ^^^^^^^^^^^^
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212
= note: expected signature `fn(_) -> impl Future<Output = &'static str>`
1313
found signature `fn(_) -> impl Future<Output = &'static str>`
1414

0 commit comments

Comments
 (0)