]>
git.proxmox.com Git - rustc.git/blob - src/librustc_middle/ty/query/job.rs
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 gcx_ptr
= tls
::GCX_PTR
.with(|gcx_ptr
| gcx_ptr
as *const _
);
14 let gcx_ptr
= &*gcx_ptr
;
16 let rustc_span_globals
=
17 rustc_span
::GLOBALS
.with(|rustc_span_globals
| rustc_span_globals
as *const _
);
18 let rustc_span_globals
= &*rustc_span_globals
;
19 let syntax_globals
= rustc_ast
::attr
::GLOBALS
.with(|syntax_globals
| syntax_globals
as *const _
);
20 let syntax_globals
= &*syntax_globals
;
21 thread
::spawn(move || {
22 tls
::GCX_PTR
.set(gcx_ptr
, || {
23 rustc_ast
::attr
::GLOBALS
.set(syntax_globals
, || {
25 .set(rustc_span_globals
, || tls
::with_global(|tcx
| deadlock(tcx
, ®istry
)))