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

Cannot derive Send bound when a value of associated type with lifetime bound where clause across await point. #93323

Closed
zirconium-n opened this issue Jan 26, 2022 · 2 comments
Labels
C-bug Category: This is a bug.

Comments

@zirconium-n
Copy link
Contributor

zirconium-n commented Jan 26, 2022

I tried this code:

#![feature(generic_associated_types)]

trait Foo<'ctx, 'env> {
    type X: Send + Sync + 'env
    where
        'env: 'ctx;
}

fn foo<'ctx, 'env: 'ctx, T: Foo<'ctx, 'env>>(x: T::X) -> impl Send + 'env + 'ctx {
    async move {
        let x = x;
        std::future::ready(()).await;
    }
}

I expected to see this happen: compile success

Instead, this happened: compile failed with error message:

error[E0478]: lifetime bound not satisfied
 --> src/main.rs:9:58
  |
9 | fn foo<'ctx, 'env: 'ctx, T: Foo<'ctx, 'env>>(x: T::X) -> impl Send + 'env + 'ctx {
  |   

The error message says it's a lifetime bound but it's not. If I change impl Send to impl Sized then it compiles.

Meta

rustc --version --verbose:

rustc 1.60.0-nightly (51126be1b 2022-01-24)
binary: rustc
commit-hash: 51126be1b260216b41143469086e6e6ee567647e
commit-date: 2022-01-24
host: x86_64-unknown-linux-gnu
release: 1.60.0-nightly
LLVM version: 13.0.0
Backtrace

<backtrace>

@zirconium-n zirconium-n added the C-bug Category: This is a bug. label Jan 26, 2022
@zirconium-n
Copy link
Contributor Author

The code itself does not use GAT, but where bound on associated types is feature-gated by GAT.

@zirconium-n
Copy link
Contributor Author

Seems a duplicate of #64552,

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