Closed

Description
Hello,
I have a weird compiler error when using Arc to store boxed closures:
use std::sync::Arc;
fn test() {
let command = Arc::new(Box::new(|&:| {}));
command();
}
It gives the following error:
src/lib.rs:7:5: 7:12 error: internal compiler error: the 1th autoderef failed: _
src/lib.rs:7 command();
^~~~~~~
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
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:126
stack backtrace:
1: 0x7f57f9a9b830 - sys::backtrace::write::hd2229fdc498b155b6St
2: 0x7f57f9abd210 - failure::on_fail::h52544b4c202b33caN6z
3: 0x7f57f9a2bfe0 - rt::unwind::begin_unwind_inner::he6cc32870f98504cGLz
4: 0x7f57f46a38b0 - rt::unwind::begin_unwind::h5028088592122257597
5: 0x7f57f46a3840 - diagnostic::SpanHandler::span_bug::ha02ae79073f0259fUoF
6: 0x7f57f7b7eab0 - session::Session::span_bug::h440c9e8057d38ac5Vlr
7: 0x7f57f91e1920 - check::FnCtxt<'a, 'tcx>::adjust_expr_ty::hcaf3bbfd460a7365Drm
8: 0x7f57f920ef60 - check::FnCtxt<'a, 'tcx>.mc..Typer<'tcx>::expr_ty_adjusted::h0f8e83db1b02cc86XFk
9: 0x7f57f9212910 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'tcx, TYPER>::walk_expr::h10929185585118381378
10: 0x7f57f92151c0 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'tcx, TYPER>::consume_expr::h11741319622797254327
11: 0x7f57f9212420 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'tcx, TYPER>::walk_block::h12439797694493826018
12: 0x7f57f920b560 - check::upvar::AdjustBorrowKind<'a, 'tcx>::analyze_fn::h13e359b42bcc8b57VCi
13: 0x7f57f9240610 - check::check_bare_fn::hffadae81e4007be9dRk
14: 0x7f57f9238200 - check::check_item::h3bf28addfabe454309k
15: 0x7f57f9306000 - check_crate::unboxed_closure.31196
16: 0x7f57f9300b30 - check_crate::h5f2f6114d5b4a8c6ayy
17: 0x7f57f9fee6d0 - driver::phase_3_run_analysis_passes::ha9cd96ebba259867aGa
18: 0x7f57f9fdbef0 - driver::compile_input::hb0db4842b7b65520Aba
19: 0x7f57fa09da40 - run_compiler::h5a4f503c8f751442lac
20: 0x7f57fa09c1b0 - thunk::F.Invoke<A, R>::invoke::h14750395715685073347
21: 0x7f57fa09b110 - rt::unwind::try::try_fn::h11237913591935978741
22: 0x7f57f9b24280 - rust_try_inner
23: 0x7f57f9b24270 - rust_try
24: 0x7f57fa09b3c0 - thunk::F.Invoke<A, R>::invoke::h1317937348465981424
25: 0x7f57f9aaaeb0 - sys::thread::thread_start::h229ade6143a76a02TKw
26: 0x7f57f3ebe0c0 - start_thread
27: 0x7f57f96ccfd9 - __clone
28: 0x0 - <unknown>
However, the following code works:
use std::sync::Arc;
use std::ops::Deref;
fn test() {
let command = Arc::new(Box::new(|&:| {}));
let intermediate = command.deref();
intermediate();
}
rustc --version
rustc 1.0.0-nightly (ed530d7a3 2015-01-16 22:41:16 +0000)