Skip to content

ICE with Unboxed Closures and HRTB #81273

Closed
@svenknobloch

Description

@svenknobloch

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions