Skip to content

Commit 5518d19

Browse files
committed
Guess head span of async blocks
1 parent 7fd9c7e commit 5518d19

File tree

4 files changed

+6
-16
lines changed

4 files changed

+6
-16
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,6 +1680,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
16801680
));
16811681

16821682
let original_span = err.span.primary_span().unwrap();
1683+
let original_span = self.tcx.sess.source_map().guess_head_span(original_span);
16831684
let mut span = MultiSpan::from_span(original_span);
16841685

16851686
let message = outer_generator

src/test/ui/async-await/issue-64130-4-async-move.stderr

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
error: future cannot be sent between threads safely
22
--> $DIR/issue-64130-4-async-move.rs:17:5
33
|
4-
LL | / async move {
5-
LL | |
6-
LL | | match client.status() {
7-
LL | | 200 => {
8-
... |
9-
LL | | }
10-
LL | | }
11-
| |_____^ future created by async block is not `Send`
4+
LL | async move {
5+
| ^^^^^^^^^^ future created by async block is not `Send`
126
|
137
= help: the trait `Sync` is not implemented for `(dyn Any + Send + 'static)`
148
note: future is not `Send` as this value is used across an await

src/test/ui/async-await/issue-70818.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: future cannot be sent between threads safely
22
--> $DIR/issue-70818.rs:5:5
33
|
44
LL | async { (ty, ty1) }
5-
| ^^^^^^^^^^^^^^^^^^^ future created by async block is not `Send`
5+
| ^^^^^ future created by async block is not `Send`
66
|
77
note: captured value is not `Send`
88
--> $DIR/issue-70818.rs:5:18

src/test/ui/async-await/issue-70935-complex-spans.stderr

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
error: future cannot be sent between threads safely
22
--> $DIR/issue-70935-complex-spans.rs:11:5
33
|
4-
LL | / async move {
5-
LL | |
6-
LL | | baz(|| async{
7-
LL | | foo(tx.clone());
8-
LL | | }).await;
9-
LL | | }
10-
| |_____^ future created by async block is not `Send`
4+
LL | async move {
5+
| ^^^^^^^^^^ future created by async block is not `Send`
116
|
127
= help: the trait `Sync` is not implemented for `Sender<i32>`
138
note: future is not `Send` as this value is used across an await

0 commit comments

Comments
 (0)