Skip to content

ICE with Unboxed Closures and HRTB #81273

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

Closed
svenknobloch opened this issue Jan 22, 2021 · 1 comment
Closed

ICE with Unboxed Closures and HRTB #81273

svenknobloch opened this issue Jan 22, 2021 · 1 comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@svenknobloch
Copy link

Playground

Code

#![feature(unboxed_closures)]

use std::future::Future;

use futures::future::LocalBoxFuture;


pub trait GenericTask<C>: 'static {
    fn execute<'a>(&'a self, ctx: &'a C) -> LocalBoxFuture<'a, ()>;
}

impl<C: 'static, T: 'static> GenericTask<C> for T
where
    T: for<'a> Fn<(&'a C, )>,
    for<'a> <T as FnOnce<(&'a C, )>>::Output: Future<Output = ()> + 'a,
{
    fn execute<'a>(&'a self, ctx: &'a C) -> LocalBoxFuture<'a, ()> {
        let future = (self)(ctx);

        Box::pin(async move {
            future.await;
        })
    }
}

Error output

   Compiling playground v0.0.1 (/playground)
error: internal compiler error: compiler/rustc_mir/src/borrow_check/universal_regions.rs:768:36: cannot convert `RePlaceholder(Placeholder { universe: U4, name: BrNamed(DefId(0:13 ~ playground[8973]::{impl#0}::'a#1), 'a) })` to a region vid

thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:958:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.51.0-nightly (202720bf4 2021-01-21) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [mir_borrowck] borrow-checking `<T as GenericTask<C>>::execute`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

error: could not compile `playground`

To learn more, run the command again with --verbose.
@svenknobloch svenknobloch added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 22, 2021
@SNCPlay42
Copy link
Contributor

Duplicate of #76168

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. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants