Skip to content

async_fn_in_trait: return type of method impl is not checked in default bodies #103352

Closed
@fasterthanlime

Description

@fasterthanlime

Here's a MVCE:

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

pub trait Foo {
    // This should be a compile error, but isn't:
    //
    async fn woopsie_async(&self) -> String {
        42
    }

    // This one is checked correctly:
    //
    // fn woopsie(&self) -> String {
    //     42
    // }
}

Playground link

I expected to see this happen: compilation fails because I'm clearly returning an {integer} instead of a String

Instead, this happened: bad codegen ("async fn resumed after completion")

Meta

rustc --version --verbose:

rustc -vV
rustc 1.66.0-nightly (dcb376115 2022-10-20)
binary: rustc
commit-hash: dcb376115066d111dbf5f13d5ac2a2dbe8c12add
commit-date: 2022-10-20
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.2
amos@sonic ~/work/hring afit
❯ rustc --version --verbose
rustc 1.66.0-nightly (dcb376115 2022-10-20)
binary: rustc
commit-hash: dcb376115066d111dbf5f13d5ac2a2dbe8c12add
commit-date: 2022-10-20
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.2

Metadata

Metadata

Labels

C-bugCategory: This is a bug.F-async_fn_in_traitStatic async fn in traitsF-return_position_impl_trait_in_trait`#![feature(return_position_impl_trait_in_trait)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions