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

Prove closure bound for TAIT, lifetime bound not satisfied #100267

Closed
LYF1999 opened this issue Aug 8, 2022 · 5 comments · Fixed by #103008
Closed

Prove closure bound for TAIT, lifetime bound not satisfied #100267

LYF1999 opened this issue Aug 8, 2022 · 5 comments · Fixed by #103008
Assignees
Labels
C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@LYF1999
Copy link
Contributor

LYF1999 commented Aug 8, 2022

I tried this code:

#![feature(generic_associated_types)]
#![feature(type_alias_impl_trait)]

use std::future::Future;

pub trait Service<Cx, Request> {
    type Response;
    type Future<'cx>: Future<Output = Self::Response> + Send + 'cx
    where
        Cx: 'cx,
        Self: 'cx;

    fn call<'cx, 's>(&'s mut self, cx: &'cx mut Cx, req: Request) -> Self::Future<'cx>
    where
        's: 'cx;
}

pub struct Test<S>(S);

impl<Cx, Req, S> Service<Cx, Req> for Test<S>
where
    Req: Send + 'static,
    S: Service<Cx, Req> + Send + 'static,
    Cx: Send + 'static,
{
    type Response = S::Response;

    type Future<'cx> = impl Send + Future<Output = Self::Response> + 'cx
    where
        Cx: 'cx,
        Self: 'cx;

    fn call<'cx, 's>(&'s mut self, cx: &'cx mut Cx, req: Req) -> Self::Future<'cx>
    where
        's: 'cx,
    {
        async move { self.0.call(cx, req).await }
    }
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.65.0-nightly (d394408fb 2022-08-07)
binary: rustc
commit-hash: d394408fb38c4de61f765a3ed5189d2731a1da91
commit-date: 2022-08-07
host: aarch64-apple-darwin
release: 1.65.0-nightly
LLVM version: 14.0.6
Backtrace

 Compiling rust_prove_closure_bug v0.1.0 (/Users/yifei/code/rust_prove_closure_bug)
error[E0478]: lifetime bound not satisfied
  --> src/main.rs:28:24
   |
28 |     type Future<'cx> = impl Send + Future<Output = Self::Response> + 'cx
   |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: lifetime parameter instantiated with the empty lifetime
note: but lifetime parameter must outlive the lifetime `'cx` as defined here
  --> src/main.rs:28:17
   |
28 |     type Future<'cx> = impl Send + Future<Output = Self::Response> + 'cx
   |                 ^^^

For more information about this error, try `rustc --explain E0478`.

@LYF1999 LYF1999 added the C-bug Category: This is a bug. label Aug 8, 2022
@LYF1999
Copy link
Contributor Author

LYF1999 commented Aug 8, 2022

I found this error occurred by this commit caee496 through cargo-bisect-rustc

@compiler-errors
Copy link
Member

Probably #98835 cc @aliemjay

@aliemjay
Copy link
Member

aliemjay commented Aug 8, 2022

Minimized:

#![feature(type_alias_impl_trait)]

type Fut<'a> = impl Sized;

fn call<'cx, 's>() -> Fut<'cx>
where
    's: 'cx,
{
    || {}
}

@rustbot claim
@rustbot label F-type_alias_impl_trait T-compiler

@rustbot rustbot added F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 8, 2022
@PureWhiteWu
Copy link

This has caused crate volo and motore docs fail to build.
https://docs.rs/crate/volo/latest
https://docs.rs/crate/motore/latest

@yshui
Copy link
Contributor

yshui commented Sep 17, 2022

This just upgraded from bad diagnostics to ICE on latest nightly.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 13, 2022
…li-obk

replace ReErased with fresh region vars in opaque types

See inline comments.

Prior art rust-lang#102943. cc `@compiler-errors` `@oli-obk`

Fixes rust-lang#100267
Fixes rust-lang#101940
Fixes rust-lang#102649
Fixes rust-lang#102510
@bors bors closed this as completed in 059bbf7 Oct 14, 2022
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. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
6 participants