Skip to content

Commit f5ee3b4

Browse files
committed
Point at async fn return type instead of body in E0746
1 parent f9ccc9a commit f5ee3b4

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,6 +1913,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
19131913
// and
19141914
// async fn foo() -> dyn Display Box<dyn { .. }>
19151915
span = fn_sig.decl.output.span();
1916+
err.span(span);
19161917
}
19171918
let body = self.tcx.hir_body_owned_by(obligation.cause.body_id);
19181919

tests/ui/async-await/async-fn/dyn-in-return-type.stderr

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
error[E0746]: return type cannot be a trait object without pointer indirection
2-
--> $DIR/dyn-in-return-type.rs:3:38
2+
--> $DIR/dyn-in-return-type.rs:3:17
33
|
4-
LL | async fn f() -> dyn core::fmt::Debug {
5-
| ______________________________________^
6-
... |
7-
LL | | }
8-
| |_^ doesn't have a size known at compile-time
4+
LL | async fn f() -> dyn core::fmt::Debug {
5+
| ^^^^^^^^^^^^^^^^^^^^
96
|
107
help: consider returning an `impl Trait` instead of a `dyn Trait`
118
|

0 commit comments

Comments
 (0)