Point at async fn return type instead of body in E0746

This commit is contained in:
Esteban Küber
2025-11-05 18:28:44 +00:00
parent 60b227accc
commit e2168b1da1
2 changed files with 4 additions and 6 deletions
@@ -1918,6 +1918,7 @@ pub(super) fn suggest_impl_trait(
// and
// async fn foo() -> dyn Display Box<dyn { .. }>
span = fn_sig.decl.output.span();
err.span(span);
}
let body = self.tcx.hir_body_owned_by(obligation.cause.body_id);
@@ -1,11 +1,8 @@
error[E0746]: return type cannot be a trait object without pointer indirection
--> $DIR/dyn-in-return-type.rs:3:38
--> $DIR/dyn-in-return-type.rs:3:17
|
LL | async fn f() -> dyn core::fmt::Debug {
| ______________________________________^
... |
LL | | }
| |_^ doesn't have a size known at compile-time
LL | async fn f() -> dyn core::fmt::Debug {
| ^^^^^^^^^^^^^^^^^^^^
|
help: consider returning an `impl Trait` instead of a `dyn Trait`
|