Closed
Description
While trying to grok/update some old code, I found that an ICE occurs in the following (invalid) code:
#![feature(slicing_syntax)]
#![feature(unboxed_closures)]
#![crate_type = "lib"]
use std::cell::RefCell;
use std::sync::Mutex;
pub struct InductionSeq<T> {
recursor: fn(&[T]) -> T,
cache: Mutex<RefCell<Vec<T>>>,
}
impl<T> InductionSeq<T> {
fn grow_cache_one(&self) {
let mut cache = self.cache.lock().unwrap().borrow_mut();
let recursor: Box<Fn(&[T]) -> T> = box self.recursor;
let new_item = recursor.call((cache[],));
}
}
The error/output:
inf_seq.rs:18:36: 18:42 error: type `std::sync::mutex::Mutex<core::cell::RefCell<collections::vec::Vec<T>>>` does not implement any method in scope named `lock`
inf_seq.rs:18 let mut cache = self.cache.lock().unwrap().borrow_mut();
^~~~~~
error: internal compiler error: no type for node 68: expr (id=68) in fcx 0x30a517e51f8
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:182
stack backtrace:
1: 0x30a593d22d0 - sys::backtrace::write::h8532e701ef86014f4it
2: 0x30a593f7b00 - failure::on_fail::h7532e1f79d134d5dzvz
3: 0x30a5935d1c0 - rt::unwind::begin_unwind_inner::h97b151606151d62deaz
4: 0x30a5422fc60 - rt::unwind::begin_unwind::h15809447133099964284
5: 0x30a54230510 - diagnostic::Handler::bug::h8818b567cf47e6a0DLF
6: 0x30a5756acf0 - session::Session::bug::h251da16737c526c0lrq
7: 0x30a58990ec0 - check::FnCtxt<'a, 'tcx>::node_ty::h8b4513e3177b34b9FAl
8: 0x30a589a6390 - check::writeback::WritebackCx<'cx, 'tcx>::visit_node_id::hadb4e437b164af77oDb
9: 0x30a589a2620 - check::writeback::WritebackCx<'cx, 'tcx>.Visitor<'v>::visit_expr::h773756089457ec03otb
10: 0x30a589a2620 - check::writeback::WritebackCx<'cx, 'tcx>.Visitor<'v>::visit_expr::h773756089457ec03otb
11: 0x30a589a2620 - check::writeback::WritebackCx<'cx, 'tcx>.Visitor<'v>::visit_expr::h773756089457ec03otb
12: 0x30a589a6290 - check::writeback::WritebackCx<'cx, 'tcx>.Visitor<'v>::visit_block::h73bb9a8ed95e2890Dub
13: 0x30a58a76b40 - check::check_bare_fn::h592fda8aa741d710Qtj
14: 0x30a58a7cf70 - check::check_method_body::ha0d2d56085b511095Vj
15: 0x30a58a6e170 - check::check_item::h9827005a9cde6421CMj
16: 0x30a58c0efe0 - check_crate::unboxed_closure.40162
17: 0x30a58c09c30 - check_crate::h19fb6dea5733566ajsx
18: 0x30a59923640 - driver::phase_3_run_analysis_passes::h46b1604d9f9f5633Tva
19: 0x30a59911ae0 - driver::compile_input::h68b8602933aad8d7wba
20: 0x30a599dceb0 - thunk::F.Invoke<A, R>::invoke::h18029802347644288836
21: 0x30a599dbc60 - rt::unwind::try::try_fn::h6518866316425934196
22: 0x30a5945e400 - rust_try_inner
23: 0x30a5945e3f0 - rust_try
24: 0x30a599dbfb0 - thunk::F.Invoke<A, R>::invoke::h15513809553472565307
25: 0x30a593e3e40 - sys::thread::thread_start::h5ea7ba97235331d5a9v
26: 0x30a53a541a0 - <unknown>
27: 0x30a590142b9 - clone
28: 0x0 - <unknown>