3 use rustc_query_system::query::deadlock;
4 use rustc_rayon_core as rayon_core;
7 /// Creates a new thread and forwards information in thread locals to it.
8 /// The new thread runs the deadlock handler.
9 /// Must only be called when a deadlock is about to happen.
10 pub unsafe fn handle_deadlock() {
11 let registry = rayon_core::Registry::current();
13 let context = tls::get_tlv();
14 assert!(context != 0);
15 rustc_data_structures::sync::assert_sync::<tls::ImplicitCtxt<'_, '_>>();
16 let icx: &tls::ImplicitCtxt<'_, '_> = &*(context as *const tls::ImplicitCtxt<'_, '_>);
18 let session_globals = rustc_span::SESSION_GLOBALS.with(|sg| sg as *const _);
19 let session_globals = &*session_globals;
20 thread::spawn(move || {
21 tls::enter_context(icx, |_| {
22 rustc_span::SESSION_GLOBALS
23 .set(session_globals, || tls::with(|tcx| deadlock(tcx, ®istry)))