Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AFIT: confusing error message with supertraits #112627

Closed
bugadani opened this issue Jun 14, 2023 · 1 comment
Closed

AFIT: confusing error message with supertraits #112627

bugadani opened this issue Jun 14, 2023 · 1 comment
Labels
C-bug Category: This is a bug.

Comments

@bugadani
Copy link
Contributor

I tried this code godbolt:

#![feature(async_fn_in_trait)]

pub trait Bar: Foo {
    async fn bar(&mut self) -> Result<(), ()>;
}

pub trait Foo {
    async fn foo(&mut self) -> Result<(), ()>;
}

impl<B: Bar> Foo for B {
    async fn foo(&mut self) -> Result<(), ()> {
        self.bar().await
    }
}

I expected to see this happen: my code compiles (as it does without AFIT), or the compiler tells me something useful.

Instead, this happened: rustc gave me a very confusing error:

error[E0053]: method `foo` has an incompatible type for trait
  --> <source>:12:32
   |
12 |     async fn foo(&mut self) -> Result<(), ()> {
   |                                ^^^^^^^^^^^^^^ expected associated type, found future
   |
note: type in trait
  --> <source>:8:32
   |
8  |     async fn foo(&mut self) -> Result<(), ()>;
   |                                ^^^^^^^^^^^^^^
   = note: expected signature `fn(&mut B) -> impl Future<Output = Result<(), ()>>`
              found signature `fn(&mut B) -> impl Future<Output = Result<(), ()>>`

Meta

rustc --version --verbose:

rustc 1.72.0-nightly (371994e0d 2023-06-13)
@bugadani bugadani added the C-bug Category: This is a bug. label Jun 14, 2023
@bugadani
Copy link
Contributor Author

Duplicate of #112626

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

1 participant