mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
QueryContext: rename try_collect_active_jobs -> collect_active_jobs and change it's return type from Option<QueryMap> to QueryMap
As there currently always Some(...) inside
This commit is contained in:
parent
b29a1e00f8
commit
31d99836bf
@ -126,11 +126,8 @@ pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
|
|||||||
.deadlock_handler(|| {
|
.deadlock_handler(|| {
|
||||||
// On deadlock, creates a new thread and forwards information in thread
|
// On deadlock, creates a new thread and forwards information in thread
|
||||||
// locals to it. The new thread runs the deadlock handler.
|
// locals to it. The new thread runs the deadlock handler.
|
||||||
let query_map = FromDyn::from(tls::with(|tcx| {
|
let query_map =
|
||||||
QueryCtxt::new(tcx)
|
FromDyn::from(tls::with(|tcx| QueryCtxt::new(tcx).collect_active_jobs()));
|
||||||
.try_collect_active_jobs()
|
|
||||||
.expect("active jobs shouldn't be locked in deadlock handler")
|
|
||||||
}));
|
|
||||||
let registry = rayon_core::Registry::current();
|
let registry = rayon_core::Registry::current();
|
||||||
thread::spawn(move || deadlock(query_map.into_inner(), ®istry));
|
thread::spawn(move || deadlock(query_map.into_inner(), ®istry));
|
||||||
});
|
});
|
||||||
|
@ -80,14 +80,14 @@ impl QueryContext for QueryCtxt<'_> {
|
|||||||
tls::with_related_context(self.tcx, |icx| icx.query)
|
tls::with_related_context(self.tcx, |icx| icx.query)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_collect_active_jobs(self) -> Option<QueryMap> {
|
fn collect_active_jobs(self) -> QueryMap {
|
||||||
let mut jobs = QueryMap::default();
|
let mut jobs = QueryMap::default();
|
||||||
|
|
||||||
for collect in super::TRY_COLLECT_ACTIVE_JOBS.iter() {
|
for collect in super::TRY_COLLECT_ACTIVE_JOBS.iter() {
|
||||||
collect(self.tcx, &mut jobs);
|
collect(self.tcx, &mut jobs);
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(jobs)
|
jobs
|
||||||
}
|
}
|
||||||
|
|
||||||
// Interactions with on_disk_cache
|
// Interactions with on_disk_cache
|
||||||
@ -155,12 +155,12 @@ impl QueryContext for QueryCtxt<'_> {
|
|||||||
fn depth_limit_error(self, job: QueryJobId) {
|
fn depth_limit_error(self, job: QueryJobId) {
|
||||||
let mut span = None;
|
let mut span = None;
|
||||||
let mut layout_of_depth = None;
|
let mut layout_of_depth = None;
|
||||||
if let Some(map) = self.try_collect_active_jobs() {
|
if let Some((info, depth)) =
|
||||||
if let Some((info, depth)) = job.try_find_layout_root(map, dep_kinds::layout_of) {
|
job.try_find_layout_root(self.collect_active_jobs(), dep_kinds::layout_of)
|
||||||
|
{
|
||||||
span = Some(info.job.span);
|
span = Some(info.job.span);
|
||||||
layout_of_depth = Some(LayoutOfDepth { desc: info.query.description, depth });
|
layout_of_depth = Some(LayoutOfDepth { desc: info.query.description, depth });
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let suggested_limit = match self.recursion_limit() {
|
let suggested_limit = match self.recursion_limit() {
|
||||||
Limit(0) => Limit(2),
|
Limit(0) => Limit(2),
|
||||||
|
@ -620,13 +620,13 @@ pub fn print_query_stack<Qcx: QueryContext>(
|
|||||||
// state if it was responsible for triggering the panic.
|
// state if it was responsible for triggering the panic.
|
||||||
let mut count_printed = 0;
|
let mut count_printed = 0;
|
||||||
let mut count_total = 0;
|
let mut count_total = 0;
|
||||||
let query_map = qcx.try_collect_active_jobs();
|
let query_map = qcx.collect_active_jobs();
|
||||||
|
|
||||||
if let Some(ref mut file) = file {
|
if let Some(ref mut file) = file {
|
||||||
let _ = writeln!(file, "\n\nquery stack during panic:");
|
let _ = writeln!(file, "\n\nquery stack during panic:");
|
||||||
}
|
}
|
||||||
while let Some(query) = current_query {
|
while let Some(query) = current_query {
|
||||||
let Some(query_info) = query_map.as_ref().and_then(|map| map.get(&query)) else {
|
let Some(query_info) = query_map.get(&query) else {
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
if Some(count_printed) < num_frames || num_frames.is_none() {
|
if Some(count_printed) < num_frames || num_frames.is_none() {
|
||||||
|
@ -106,7 +106,7 @@ pub trait QueryContext: HasDepContext {
|
|||||||
/// Get the query information from the TLS context.
|
/// Get the query information from the TLS context.
|
||||||
fn current_query_job(self) -> Option<QueryJobId>;
|
fn current_query_job(self) -> Option<QueryJobId>;
|
||||||
|
|
||||||
fn try_collect_active_jobs(self) -> Option<QueryMap>;
|
fn collect_active_jobs(self) -> QueryMap;
|
||||||
|
|
||||||
/// Load side effects associated to the node in the previous session.
|
/// Load side effects associated to the node in the previous session.
|
||||||
fn load_side_effects(self, prev_dep_node_index: SerializedDepNodeIndex) -> QuerySideEffects;
|
fn load_side_effects(self, prev_dep_node_index: SerializedDepNodeIndex) -> QuerySideEffects;
|
||||||
|
@ -242,11 +242,8 @@ where
|
|||||||
Q: QueryConfig<Qcx>,
|
Q: QueryConfig<Qcx>,
|
||||||
Qcx: QueryContext,
|
Qcx: QueryContext,
|
||||||
{
|
{
|
||||||
let error = try_execute.find_cycle_in_stack(
|
let error =
|
||||||
qcx.try_collect_active_jobs().unwrap(),
|
try_execute.find_cycle_in_stack(qcx.collect_active_jobs(), &qcx.current_query_job(), span);
|
||||||
&qcx.current_query_job(),
|
|
||||||
span,
|
|
||||||
);
|
|
||||||
(mk_cycle(query, qcx, error), None)
|
(mk_cycle(query, qcx, error), None)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user