Skip to content

Commit 5b92150

Browse files
committed
Remove deadlock virtual call.
1 parent 81241cb commit 5b92150

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

compiler/rustc_interface/src/util.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ use rustc_errors::registry::Registry;
1010
use rustc_metadata::dynamic_lib::DynamicLibrary;
1111
#[cfg(parallel_compiler)]
1212
use rustc_middle::ty::tls;
13+
#[cfg(parallel_compiler)]
14+
use rustc_query_impl::QueryCtxt;
1315
use rustc_resolve::{self, Resolver};
1416
use rustc_session as session;
1517
use rustc_session::config::{self, CrateType};
@@ -176,7 +178,7 @@ unsafe fn handle_deadlock() {
176178
thread::spawn(move || {
177179
tls::enter_context(icx, |_| {
178180
rustc_span::set_session_globals_then(session_globals, || {
179-
tls::with(|tcx| tcx.queries.deadlock(tcx, &registry))
181+
tls::with(|tcx| QueryCtxt::from_tcx(tcx).deadlock(&registry))
180182
})
181183
});
182184
});

compiler/rustc_middle/src/ty/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ use std::mem;
7171
use std::ops::{Bound, Deref};
7272
use std::sync::Arc;
7373

74-
pub trait OnDiskCache<'tcx> {
74+
pub trait OnDiskCache<'tcx>: rustc_data_structures::sync::Sync {
7575
/// Creates a new `OnDiskCache` instance from the serialized data in `data`.
7676
fn new(sess: &'tcx Session, data: Vec<u8>, start_pos: usize) -> Self
7777
where

compiler/rustc_middle/src/ty/query.rs

-3
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,6 @@ macro_rules! define_callbacks {
233233
pub trait QueryEngine<'tcx>: rustc_data_structures::sync::Sync {
234234
fn as_any(&'tcx self) -> &'tcx dyn std::any::Any;
235235

236-
#[cfg(parallel_compiler)]
237-
unsafe fn deadlock(&'tcx self, tcx: TyCtxt<'tcx>, registry: &rustc_rayon_core::Registry);
238-
239236
fn try_mark_green(&'tcx self, tcx: TyCtxt<'tcx>, dep_node: &dep_graph::DepNode) -> bool;
240237

241238
$($(#[$attr])*

compiler/rustc_query_impl/src/plumbing.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ impl<'tcx> QueryCtxt<'tcx> {
155155
self.queries.on_disk_cache.as_ref()
156156
}
157157

158+
#[cfg(parallel_compiler)]
159+
pub unsafe fn deadlock(self, registry: &rustc_rayon_core::Registry) {
160+
rustc_query_system::query::deadlock(self, registry)
161+
}
162+
158163
pub(super) fn encode_query_results(
159164
self,
160165
encoder: &mut on_disk_cache::CacheEncoder<'a, 'tcx, opaque::FileEncoder>,
@@ -537,12 +542,6 @@ macro_rules! define_queries_struct {
537542
this as _
538543
}
539544

540-
#[cfg(parallel_compiler)]
541-
unsafe fn deadlock(&'tcx self, tcx: TyCtxt<'tcx>, registry: &rustc_rayon_core::Registry) {
542-
let tcx = QueryCtxt { tcx, queries: self };
543-
rustc_query_system::query::deadlock(tcx, registry)
544-
}
545-
546545
fn try_mark_green(&'tcx self, tcx: TyCtxt<'tcx>, dep_node: &dep_graph::DepNode) -> bool {
547546
let qcx = QueryCtxt { tcx, queries: self };
548547
tcx.dep_graph.try_mark_green(qcx, dep_node).is_some()

0 commit comments

Comments
 (0)