Closed
Description
Panic when trying to enforce Send
on a impl parameter of type Self
. Panics with meaningful error. Should perhaps just be a regular compiler error?
I tried this code:
pub trait SpawnableTaskTrait<Self: Send> {
fn spawn(syncy_self: Arc<Mutex<Self>>) where Self: Send {
let thread_this = syncy_self.clone();
let signal = Arc::new(AtomicBool::new(false));
let signal_clone = signal.clone();
thread::spawn(move || {
let this = thread_this;
loop {
{
let mut this = this.lock().unwrap();
let res = Self::werk()(&mut this);
match res {
Ok(_) => continue,
Err(err) => {
if err.description() == "Resource temporarily unavailable" || err.description() == "operation would block" {
continue
} else {
panic!("omg: {:?}", err)
}
}
}
}
if signal_clone.load(Ordering::Relaxed) {
break
}
}
});
}
}
I expected to see this happen: meaningful error or it would work!
Instead, this happened: panic in rustc
Meta
rustc --version --verbose
:
Xaviers-MacBook-Pro-2:~ xavierlange$ rustc --version --verbose
rustc 1.13.0-nightly (a7b2232d2 2016-09-07)
binary: rustc
commit-hash: a7b2232d20320dc3b4044a2aec1d51a129e7e17d
commit-date: 2016-09-07
host: x86_64-apple-darwin
release: 1.13.0-nightly
Backtrace:
error: internal compiler error: ../src/librustc_typeck/collect.rs:1925: `Self` should not be the name of a regular parameter
thread 'rustc' panicked at 'Box<Any>', ../src/librustc_errors/lib.rs:590
stack backtrace:
1: 0x10f45157a - std::sys::backtrace::tracing::imp::write::h46f28e67d38b4637
2: 0x10f45fc7f - std::panicking::default_hook::{{closure}}::h1d3243f546573ff4
3: 0x10f45e31d - std::panicking::default_hook::h96c288d728df3ebf
4: 0x10f45e9b6 - std::panicking::rust_panic_with_hook::hb1322e5f2588b4db
5: 0x10b102d1b - std::panicking::begin_panic::hb7c71bbc491f561c
6: 0x10b2347d3 - rustc::session::opt_span_bug_fmt::{{closure}}::h0a2486f2fff54208
7: 0x10b14b9a9 - rustc::session::span_bug_fmt::heb3fdb6acac8d0c7
8: 0x10b16483e - <core::iter::Map<I, F> as core::iter::iterator::Iterator>::next::h1ff68e27aab0f019
9: 0x10b21ab21 - rustc_typeck::collect::generics_of_def_id::h3a0f77e827110638
10: 0x10b219ba9 - rustc_typeck::collect::trait_def_of_item::hed1ea083432e49c3
11: 0x10b21547b - rustc_typeck::collect::convert_item::h293968d6650e9d0b
12: 0x10b20f48e - rustc_typeck::collect::collect_item_types::ha4bc6b2aaead1c12
13: 0x10b22fff6 - rustc_typeck::check_crate::h279dc52e9bc1b4c2
14: 0x10b00b324 - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::h2b062b0c671cd504
15: 0x10afe18e7 - rustc_driver::driver::phase_3_run_analysis_passes::h2f1bd27ff2e4d8a0
16: 0x10afd3c9f - rustc_driver::driver::compile_input::h7dacd98cd2fd7d2b
17: 0x10affdc48 - rustc_driver::run_compiler::h37c4294ab73436f7
18: 0x10af410a0 - std::panicking::try::do_call::h4d040997e2efdaf3
19: 0x10f46685a - __rust_maybe_catch_panic
20: 0x10af5f394 - <F as alloc::boxed::FnBox<A>>::call_box::hefd1c85fab3e6c31
21: 0x10f45d194 - std::sys::thread::Thread::new::thread_start::h5b631f48cd23f128
22: 0x7fff8745099c - _pthread_body
23: 0x7fff87450919 - _pthread_start