Skip to content

rustc reports misc message with impl conflict of trait with AFIT and assoc type. #116982

Closed
@Berrysoft

Description

@Berrysoft

Code

trait Foo {
    type T;
    
    async fn foo(&self) -> Self::T;
}

struct Bar;

impl Foo for Bar {
    type T = ();

    async fn foo(&self) {}
}

impl Foo for Bar {
    type T = ();

    async fn foo(&self) {}
}

Current output

error[E0284]: type annotations needed: cannot satisfy `<Bar as Foo>::T == ()`
  --> src/main.rs:12:5
   |
12 |     async fn foo(&self) {}
   |     ^^^^^^^^^^^^^^^^^^^ cannot satisfy `<Bar as Foo>::T == ()`

error[E0284]: type annotations needed: cannot satisfy `<Bar as Foo>::T == ()`
  --> src/main.rs:18:5
   |
18 |     async fn foo(&self) {}
   |     ^^^^^^^^^^^^^^^^^^^ cannot satisfy `<Bar as Foo>::T == ()`

For more information about this error, try `rustc --explain E0284`.

Desired output

error[E0119]: conflicting implementations of trait `Foo` for type `Bar`
  --> src/main.rs:11:1
   |
9  | impl Foo for Bar {
   | ---------------- first implementation here
...
15 | impl Foo for Bar {
   | ^^^^^^^^^^^^^^^^ conflicting implementation for `Bar`

For more information about this error, try `rustc --explain E0119`.

Rationale and extra context

No response

Other cases

No response

Anything else?

No response

Metadata

Metadata

Labels

A-async-awaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.D-confusingDiagnostics: Confusing error or lint that should be reworked.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-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions