Open
Description
Code
trait Trait {}
async fn fun() -> Trait {
todo!()
}
fn main() {}
Current output
error[E0782]: expected a type, found a trait
--> src/main.rs:3:19
|
3 | async fn fun() -> Trait {
| ^^^^^
|
help: you can add the `dyn` keyword if you want a trait object
|
3 | async fn fun() -> dyn Trait {
| +++
help: you might have meant to write a bound here
|
1 | : Trait {
| ~
Desired output
error[E0782]: expected a type, found a trait
--> src/main.rs:3:19
|
3 | async fn fun() -> Trait {
| ^^^^^
|
help: use `impl Trait` to return an opaque type, as long as you return a single underlying type
|
3 | async fn fun() -> impl Trait {
| ++++
help: alternatively, you can return an owned trait object
|
3 | async fn fun() -> Box<dyn Trait> {
| +++++++ +
Rationale and extra context
No response
Other cases
No response
Rust Version
rustc 1.83.0-dev
binary: rustc
commit-hash: ecf2d1f
commit-date: 2024-10-13
host: x86_64-unknown-linux-gnu
release: 1.83.0-dev
LLVM version: 19.1.1
Anything else?
Originally reported in #127691 (comment)
The non-async case was fixed in #131239