Closed
Description
I tried this code:
static no_op : Box<FnMut(i32)> = Box::new(move |_| { });
fn main() {
}
I expected it to compile cleanly or give me a helpful error. Instead, it gave me a helpful error and then an ICE:
src/bug_repro.rs:1:34: 1:56 error: function calls in statics are limited to struct and enum constructors [E0015]
src/bug_repro.rs:1 static no_op : Box<FnMut(i32)> = Box::new(move |_| { });
^~~~~~~~~~~~~~~~~~~~~~
src/bug_repro.rs:1:34: 1:56 help: run `rustc --explain E0015` to see a detailed explanation
error: internal compiler error: unexpected panic
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 'assertion failed: self.mode == Mode::Var', /home/rustbuild/src/rust-buildbot/slave/stable-dist-rustc-linux/build/src/librustc/middle/check_const.rs:254
Version:
$ rustc --version --verbose
rustc 1.1.0 (35ceea399 2015-06-19)
binary: rustc
commit-hash: 35ceea3997c79a3b7562e89b462ab76af5b86b22
commit-date: 2015-06-19
host: x86_64-unknown-linux-gnu
release: 1.1.0
stack backtrace:
1: 0x7f87cd852529 - sys::backtrace::write::ha3b8868b13c6f5b594r
2: 0x7f87cd85a449 - panicking::on_panic::h0d4f0a7bb69824a9iJw
3: 0x7f87cd81b242 - rt::unwind::begin_unwind_inner::h6eae1ff9ccde81e1sow
4: 0x7f87cb69a14e - rt::unwind::begin_unwind::h5657407561811364434
5: 0x7f87cb7e0352 - middle::check_const::CheckCrateVisitor<'a, 'tcx>.Visitor<'v>::visit_fn::hd06dbbc963009a38mQd
6: 0x7f87cb7e327b - visit::walk_expr::h7428632329866803358
7: 0x7f87cb7daf58 - middle::check_const::CheckCrateVisitor<'a, 'tcx>.Visitor<'v>::visit_expr::ha2cfc0edff92e762pSd
8: 0x7f87cb7dae1e - middle::check_const::CheckCrateVisitor<'a, 'tcx>.Visitor<'v>::visit_expr::ha2cfc0edff92e762pSd
9: 0x7f87cb7c6150 - middle::check_const::CheckCrateVisitor<'a, 'tcx>::global_expr::h84b8593855198411OFd
10: 0x7f87cb7df439 - middle::check_const::CheckCrateVisitor<'a, 'tcx>.Visitor<'v>::visit_item::h07c7afb9c4056bb8tLd
11: 0x7f87cb7e799a - middle::check_const::check_crate::h91fd962e256ef08cnke
12: 0x7f87cdda222e - driver::phase_3_run_analysis_passes::h9b9e8dc3e9bbf431tGa
13: 0x7f87cdd8606c - driver::compile_input::h6e596544d26b4394Qba
14: 0x7f87cde3c041 - run_compiler::haa6c0289fab7415475b
15: 0x7f87cde39892 - boxed::F.FnBox<A>::call_box::h10721825727138786690
16: 0x7f87cde38e59 - rt::unwind::try::try_fn::h6014602198652783625
17: 0x7f87cd8d2b58 - rust_try_inner
18: 0x7f87cd8d2b45 - rust_try
19: 0x7f87cde390f4 - boxed::F.FnBox<A>::call_box::h5510246712457526188
20: 0x7f87cd8591e1 - sys::thread::Thread::new::thread_start::h11fbc90f6ba541f9zvv
21: 0x7f87c80dd6a9 - start_thread
22: 0x7f87cd4a2eec - clone
23: 0x0 - <unknown>