Skip to content

missing trait impl suggestion is not async-aware #108195

@ehuss

Description

@ehuss
Contributor

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

Activity

added
A-diagnosticsArea: Messages for errors, warnings, and lints
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
C-bugCategory: This is a bug.
A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`
D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.
on Feb 17, 2023
added a commit that references this issue on Jun 20, 2023
be68e9e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.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

Status

Done

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @ehuss@compiler-errors

    Issue actions

      missing trait impl suggestion is not async-aware · Issue #108195 · rust-lang/rust