Auto merge of #153690 - nnethercote:find_dep_kind_root, r=petrochenkov

`find_dep_kind_root` tweaks

Two minor changes relating to `find_dep_kind_root`.

r? @SparrowLii
This commit is contained in:
bors
2026-03-14 10:27:50 +00:00
2 changed files with 15 additions and 14 deletions
+11 -10
View File
@@ -46,7 +46,7 @@ fn latch_of(&self, id: QueryJobId) -> Option<&QueryLatch<'tcx>> {
}
}
#[derive(Clone, Debug)]
#[derive(Debug)]
pub(crate) struct QueryJobInfo<'tcx> {
pub(crate) frame: QueryStackFrame<'tcx>,
pub(crate) job: QueryJob<'tcx>,
@@ -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)
}
/// The locaton of a resumable waiter. The usize is the index into waiters in the query's latch.
+4 -4
View File
@@ -30,16 +30,16 @@
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),
});