Closed
Description
While trying to find the right syntax for this SO question, I came upon this:
fn foo<'a, T: 'a>(t: T) -> Box<Fn() -> &'a T + 'a> {
let foo: Box<for <'c> Fn() -> &'c T> = Box::new(move || &t);
unimplemented!()
}
fn main() {}
which ICEs on Stable, Beta and Nightly:
Compiling playground v0.0.1 (file:///playground)
error[E0582]: binding for associated type `Output` references lifetime `'c`, which does not appear in the trait input types
--> src/main.rs:2:35
|
2 | let foo: Box<for <'c> Fn() -> &'c T> = Box::new(move || &t);
| ^^^^^
error: internal compiler error: librustc/infer/higher_ranked/mod.rs:160: no representative region for `ReSkolemized(1, BrAnon(1))` in `{ReSkolemized(1, BrAnon(1))}`
thread 'rustc' panicked at 'Box<Any>', librustc_errors/lib.rs:543:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0582`.
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.26.0-beta.3 (8a75d2b50 2018-04-08) running on x86_64-unknown-linux-gnu
note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type bin
https://play.rust-lang.org/?gist=99fafbbcbd0fc919138de28d5e1a6326&version=nightly