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

missing trait impl suggestion is not async-aware #108195

Closed
ehuss opened this issue Feb 17, 2023 · 0 comments · Fixed by #112596
Closed

missing trait impl suggestion is not async-aware #108195

ehuss opened this issue Feb 17, 2023 · 0 comments · Fixed by #112596
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-bug Category: This is a bug. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. F-async_fn_in_trait Static async fn in traits T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ehuss
Copy link
Contributor

ehuss commented Feb 17, 2023

I tried this code:

#![allow(incomplete_features)]
#![feature(async_fn_in_trait)]

trait Trait {
    async fn foo();
}

struct S;

impl Trait for S {

}

When compiled will provide a (tool-only) suggestion that is not valid:

rustc --edition 2021 --error-format=json foo.rs 2>&1 | jq '.children[0].spans[0].suggested_replacement'

shows the suggestion is:

fn foo() -> impl Future<Output = ()> { todo!() }

I would expect the signature to more closely match the original trait:

async fn foo() { todo!() }

Note: The console output is:

error[E0046]: not all trait items implemented, missing: `foo`
  --> foo.rs:10:1
   |
5  |     async fn foo();
   |     --------------- `foo` from trait
...
10 | impl Trait for S {
   | ^^^^^^^^^^^^^^^^ missing `foo` in implementation

Meta

rustc --version --verbose:

rustc 1.69.0-nightly (9a7cc6c32 2023-02-16)
binary: rustc
commit-hash: 9a7cc6c32f1a690f86827e4724bcda85e506ef35
commit-date: 2023-02-16
host: aarch64-apple-darwin
release: 1.69.0-nightly
LLVM version: 15.0.7
@ehuss ehuss added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. F-async_fn_in_trait Static async fn in traits labels Feb 17, 2023
@compiler-errors compiler-errors self-assigned this Jun 13, 2023
@bors bors closed this as completed in be68e9e Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-bug Category: This is a bug. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. F-async_fn_in_trait Static async fn in traits T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
Development

Successfully merging a pull request may close this issue.

2 participants