Skip to content

async fn in trait: trait method with default impl doesn't work #102308

Closed
@Dirbaio

Description

@Dirbaio

playground

trait Foo {
    async fn bar(&mut self) {}
}

fails with

error[[E0308]](https://doc.rust-lang.org/nightly/error-index.html#E0308): mismatched types
 --> src/main.rs:5:29
  |
5 |     async fn bar(&mut self) {}
  |                             ^^ expected associated type, found opaque type
  |
  = note: expected associated type `impl Future<Output = ()>` (trait associated opaque type at <src/main.rs:5:29>)
                 found opaque type `impl Future<Output = ()>` (opaque type at </rustc/f5193a9fcc73dc09e41a90c5a2c97fc9acc16032/library/core/src/future/mod.rs:72:43>)

Nightly version: 1.66.0-nightly (2022-09-25 f5193a9)

@rustbot label +F-async_fn_in_traits

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions