Closed

Description
I was trying to compile the following code:
#![feature(core)]
#![feature(unboxed_closures)]
enum Thunk<A, F: Fn<A>> { Unevaluated(F, A), Evaluated(F::Output), }
impl <A, F: Fn<A>> Thunk<A, F> {
fn eval(self) -> (Self, F::Output) where F::Output: Copy {
match self {
Thunk::Unevaluated(f, a) => {
let r = Fn::call(&f, a);
(Thunk::Evaluated(r), r)
}
Thunk::Evaluated(r) => (self, r),
}
}
}
fn main() {
let (_, v) = Thunk::Unevaluated(|x: i32| { x + 1 }, (3,)).eval();
println!("{}" , v);
}
And got the following compiler error:
error: internal compiler error: static call to invalid vtable: VtableClosure(DefId { krate: 0, node: 97 },Substs[types=[[];[];[]], regions=eras
ed])
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: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:189
stack backtrace:
1: 0x7f77423cc210 - sys::backtrace::write::h58f3688f47ea9825KlC
2: 0x7f77423f4ac0 - panicking::on_panic::h6a53d3220988f2eebYL
3: 0x7f7742335720 - rt::unwind::begin_unwind_inner::h72a0c6e103bfcdc3zCL
4: 0x7f773f5ffde0 - rt::unwind::begin_unwind::h2955836616559227712
5: 0x7f773f6005a0 - diagnostic::Handler::bug::h3ef6141b1fad14d7r5E
6: 0x7f774034e2c0 - session::Session::bug::h912125adfec44a01Snt
7: 0x7f774103af70 - trans::meth::trans_static_method_callee::hee20b523e376bdd9mjz
8: 0x7f7741037e40 - trans::callee::trans::h6f90cc6896233847Kgg
9: 0x7f774104e040 - trans::callee::trans_call_inner::h364678376362576570
10: 0x7f7741057990 - trans::expr::trans_rvalue_dps_unadjusted::h706f4998bd14a2629Wi
11: 0x7f774100ccc0 - trans::expr::trans_into::hdab96306e19b21bcpGh
12: 0x7f7741111450 - trans::_match::mk_binding_alloca::h10439043131118879359
13: 0x7f774100c400 - trans::base::init_local::hcdcc29de8e78259fwst
14: 0x7f774100d830 - trans::controlflow::trans_block::h5bbb67526ff90a125ee
15: 0x7f7741057990 - trans::expr::trans_rvalue_dps_unadjusted::h706f4998bd14a2629Wi
16: 0x7f774100ccc0 - trans::expr::trans_into::hdab96306e19b21bcpGh
17: 0x7f77410f9260 - trans::_match::trans_match_inner::h6651c4e019791e16aMx
18: 0x7f7741057990 - trans::expr::trans_rvalue_dps_unadjusted::h706f4998bd14a2629Wi
19: 0x7f774100ccc0 - trans::expr::trans_into::hdab96306e19b21bcpGh
20: 0x7f774100d830 - trans::controlflow::trans_block::h5bbb67526ff90a125ee
21: 0x7f77410dad70 - trans::base::trans_closure::h8de4dc5484c0f3bephu
22: 0x7f7740ff9b30 - trans::base::trans_fn::h734239fd8d4c689fGsu
23: 0x7f7740ffa090 - trans::monomorphize::monomorphic_fn::he0cb46049f2b73776Ad
24: 0x7f774103c170 - trans::callee::trans_fn_ref_with_substs::h5a9f25c47377da3bYDg
25: 0x7f774103abf0 - trans::callee::trans_fn_ref::h49bed2d85d0bd0955rg
26: 0x7f7741050b90 - trans::meth::trans_method_callee::had7e320247e6010e3dz
27: 0x7f774104f640 - trans::callee::trans_call_inner::h11271674016489502486
28: 0x7f7741057990 - trans::expr::trans_rvalue_dps_unadjusted::h706f4998bd14a2629Wi
29: 0x7f7741056dd0 - trans::expr::trans_unadjusted::h4aa6c42f21ab6029sqi
30: 0x7f774100e360 - trans::expr::trans::h522d304fced36cc2HMh
31: 0x7f774100c400 - trans::base::init_local::hcdcc29de8e78259fwst
32: 0x7f774100d830 - trans::controlflow::trans_block::h5bbb67526ff90a125ee
33: 0x7f77410dad70 - trans::base::trans_closure::h8de4dc5484c0f3bephu
34: 0x7f7740ff9b30 - trans::base::trans_fn::h734239fd8d4c689fGsu
35: 0x7f7740ff4d50 - trans::base::trans_item::h653e553ae00342d4zRu
36: 0x7f77410e22e0 - trans::base::trans_crate::hffa644676f991a591Ov
37: 0x7f7742a534f0 - driver::phase_4_translate_to_llvm::h7bbc12961d2d7c58qPa
38: 0x7f7742a2d2d0 - driver::compile_input::hfb1bb38c59866d0fGba
39: 0x7f7742afc510 - run_compiler::hf2a7d9848e51e3b5Zbc
40: 0x7f7742afae10 - thunk::F.Invoke<A, R>::invoke::h12698859262113329290
41: 0x7f7742af9d00 - rt::unwind::try::try_fn::h10854600533917764358
42: 0x7f7742461880 - rust_try_inner
43: 0x7f7742461870 - rust_try
44: 0x7f7742afa000 - thunk::F.Invoke<A, R>::invoke::h4174228679526982116
45: 0x7f77423e0b60 - sys::thread::thread_start::h60ae7cb39d135ef7R4G
46: 0x7f773c2be0c0 - start_thread
47: 0x7f7741fadfd9 - __clone
48: 0x0 - <unknown>
Version info:
$ rustc --version --verbose
rustc 1.0.0-nightly (2b01a37ec 2015-02-21) (built 2015-02-22)
binary: rustc
commit-hash: 2b01a37ec38db9301239f0c0abcf3c695055b0ff
commit-date: 2015-02-21
build-date: 2015-02-22
host: x86_64-unknown-linux-gnu
release: 1.0.0-nightly