Skip to content

AFIT: strange errors on circular impls #112626

Open
@Dirbaio

Description

@Dirbaio

case 1 playground:

pub trait Foo {
    async fn foo(&mut self);
}

impl<T: Foo> Foo for T {
    async fn foo(&mut self) {}
}

case 2 playground:

pub trait Foo {
    async fn foo(&mut self);
}

pub trait Bar: Foo {
    async fn bar(&mut self);
}

impl<T: Bar> Foo for T {
    async fn foo(&mut self) {}
}

fails with a strange error. The equivalent without AFIT is accepted, but the impls are considered to apply to no type because they're circular turns out the version with 2 traits does result in usable impls, it's an odd way of doing extension traits: playground. So I do think these should compile.

error[[E0053]](https://doc.rust-lang.org/nightly/error_codes/E0053.html): method `foo` has an incompatible type for trait
 --> src/lib.rs:8:29
  |
8 |     async fn foo(&mut self) {}
  |                             ^ expected associated type, found future
  |
note: type in trait
 --> src/lib.rs:4:28
  |
4 |     async fn foo(&mut self);
  |                            ^
  = note: expected signature `fn(&mut T) -> impl Future<Output = ()>`
             found signature `fn(&mut T) -> impl Future<Output = ()>`

@rustbot label F-async_fn_in_trait

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.D-confusingDiagnostics: Confusing error or lint that should be reworked.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.F-async_fn_in_traitStatic async fn in traitsT-typesRelevant to the types team, which will review and decide on the PR/issue.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.

    Type

    No type

    Projects

    Status

    Non-blocking

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions