-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
ICE returning unboxed closure #16672
Comments
correction... the closure does not actually need to be generic. Simplified repro: #![feature(unboxed_closures)]
fn main() {
let f = |&: x:uint| {x};
let bar = foo(f);
println!("{}", bar.call((1,)));
}
fn foo<F: Fn<(uint,), uint>>(f: F) -> Box<Fn<(uint,),uint>> {
( box |&: x: uint| f.call((x,))) as Box<Fn<(uint,), uint>>
} |
Now needs explicit 'static bound to repro: #![feature(unboxed_closures)]
fn main() {
let f = |&: | { };
let bar = foo(f);
println!("{}" , bar.call (()) );
}
fn foo<F: Fn<(), ()> + 'static>(f: F) -> Box<Fn<(), ()> + 'static> {
( box |&: | f.call(())) as Box<Fn<(), ()>>
}
|
now needs move to repro: #![feature(unboxed_closures)]
fn main() {
let f = |&: | { };
let bar = foo(f);
println!("{}" , bar.call (()) );
}
fn foo<F: Fn<(), ()> + 'static>(f: F) -> Box<Fn<(), ()> + 'static> {
( box move |&: | f.call(())) as Box<Fn<(), ()>>
} error is now reported in diagnostic.rs though
backtrace
|
I think this is the same as #16791. In particular, the closure is capturing a free variable with a generic type which trans fails to monomorphize and chokes on. |
The latest example now builds for me, and I think the existing tests cover this well enough, so this issue can be closed. |
Thanks @bkoropoff! |
I get an ICE when trying to compile the following:
the ICE:
Rust version:
maybe related to #13970 ?
The text was updated successfully, but these errors were encountered: