Remove Clone derive on QueryJobInfo.

This requires refactoring `depth_limit_error` to do some extra work
immediately instead of returning a cloned `info`.
This commit is contained in:
Nicholas Nethercote
2026-03-10 14:00:45 +11:00
parent 314e224fa5
commit ddd1a69483
2 changed files with 12 additions and 10 deletions
+8 -6
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,26 +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`.
/// 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 mut info = &job_map.map[&id];
let dep_kind = info.frame.dep_kind;
let mut last_layout = (info.clone(), depth);
let mut last_info = info;
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;
}
}
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
+4 -4
View File
@@ -36,16 +36,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),
});