Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions compiler/rustc_query_impl/src/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl<'tcx> QueryJobMap<'tcx> {
}
}

#[derive(Clone, Debug)]
#[derive(Debug)]
pub(crate) struct QueryJobInfo<'tcx> {
pub(crate) frame: QueryStackFrame<'tcx>,
pub(crate) job: QueryJob<'tcx>,
Expand Down Expand Up @@ -88,27 +88,28 @@ pub(crate) fn find_cycle_in_stack<'tcx>(
panic!("did not find a cycle")
}

/// Finds the job closest to the root with a `DepKind` matching the `DepKind` of `id` and returns
/// information about it.
#[cold]
#[inline(never)]
pub(crate) fn find_dep_kind_root<'tcx>(
tcx: TyCtxt<'tcx>,
id: QueryJobId,
job_map: QueryJobMap<'tcx>,
) -> (QueryJobInfo<'tcx>, usize) {
) -> (Span, String, usize) {
let mut depth = 1;
let info = &job_map.map[&id];
let mut info = &job_map.map[&id];
let dep_kind = info.frame.dep_kind;
let mut current_id = info.job.parent;
let mut last_layout = (info.clone(), depth);
let mut last_info = info;

while let Some(id) = current_id {
let info = &job_map.map[&id];
while let Some(id) = info.job.parent {
info = &job_map.map[&id];
if info.frame.dep_kind == dep_kind {
depth += 1;
last_layout = (info.clone(), depth);
last_info = info;
}
current_id = info.job.parent;
}
last_layout
(last_info.job.span, last_info.frame.tagged_key.description(tcx), depth)
}

/// A resumable waiter of a query. The usize is the index into waiters in the query's latch
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_query_impl/src/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ use crate::{

fn depth_limit_error<'tcx>(tcx: TyCtxt<'tcx>, job: QueryJobId) {
let job_map = collect_active_jobs_from_all_queries(tcx, CollectActiveJobsKind::Full);
let (info, depth) = find_dep_kind_root(job, job_map);
let (span, desc, depth) = find_dep_kind_root(tcx, job, job_map);

let suggested_limit = match tcx.recursion_limit() {
Limit(0) => Limit(2),
limit => limit * 2,
};

tcx.sess.dcx().emit_fatal(QueryOverflow {
span: info.job.span,
note: QueryOverflowNote { desc: info.frame.tagged_key.description(tcx), depth },
tcx.dcx().emit_fatal(QueryOverflow {
span,
note: QueryOverflowNote { desc, depth },
suggested_limit,
crate_name: tcx.crate_name(LOCAL_CRATE),
});
Expand Down
Loading