Closed
Description
I know the Fn traits are unstable and are therefore completely allowed to eat my laundry and sell my dog to ISIS, but this is probably an important bug nontheless: on current nightly (rustc 1.8.0 (db2939409 2016-04-11)
, unless playground doesn't use current nightly), the following code ICEs
#![feature(unboxed_closures)]
#![feature(fn_traits)]
struct Test;
impl FnOnce<(u32, u32)> for Test {
type Output = u32;
extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 {
a + b
}
}
fn main() {
println!("{:?}", Test(1u32, 2u32));
}
It also ICEs with an empty struct definition (struct Test {}
instead of struct Test;
). The following code does not ICE:
#![feature(unboxed_closures)]
#![feature(fn_traits)]
struct Dummy;
struct Test(Dummy);
impl FnOnce<(u32, u32)> for Test {
type Output = u32;
extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 {
a + b
}
}
fn main() {
println!("{:?}", Test(Dummy)(1u32, 2u32));
}
Error message:
error: internal compiler error: ../src/librustc_trans/adt.rs:430: adt::represent_type called on non-ADT type: u32
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
thread 'rustc' panicked at 'Box<Any>', ../src/libsyntax/errors/mod.rs:584
note: Run with `RUST_BACKTRACE=1` for a backtrace.
playpen: application terminated with error code 101