Skip to content

Commit ddd1a69

Browse files
committed
Remove Clone derive on QueryJobInfo.
This requires refactoring `depth_limit_error` to do some extra work immediately instead of returning a cloned `info`.
1 parent 314e224 commit ddd1a69

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

compiler/rustc_query_impl/src/job.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl<'tcx> QueryJobMap<'tcx> {
4646
}
4747
}
4848

49-
#[derive(Clone, Debug)]
49+
#[derive(Debug)]
5050
pub(crate) struct QueryJobInfo<'tcx> {
5151
pub(crate) frame: QueryStackFrame<'tcx>,
5252
pub(crate) job: QueryJob<'tcx>,
@@ -88,26 +88,28 @@ pub(crate) fn find_cycle_in_stack<'tcx>(
8888
panic!("did not find a cycle")
8989
}
9090

91-
/// Finds the job closest to the root with a `DepKind` matching the `DepKind` of `id`.
91+
/// Finds the job closest to the root with a `DepKind` matching the `DepKind` of `id` and returns
92+
/// information about it.
9293
#[cold]
9394
#[inline(never)]
9495
pub(crate) fn find_dep_kind_root<'tcx>(
96+
tcx: TyCtxt<'tcx>,
9597
id: QueryJobId,
9698
job_map: QueryJobMap<'tcx>,
97-
) -> (QueryJobInfo<'tcx>, usize) {
99+
) -> (Span, String, usize) {
98100
let mut depth = 1;
99101
let mut info = &job_map.map[&id];
100102
let dep_kind = info.frame.dep_kind;
101-
let mut last_layout = (info.clone(), depth);
103+
let mut last_info = info;
102104

103105
while let Some(id) = info.job.parent {
104106
info = &job_map.map[&id];
105107
if info.frame.dep_kind == dep_kind {
106108
depth += 1;
107-
last_layout = (info.clone(), depth);
109+
last_info = info;
108110
}
109111
}
110-
last_layout
112+
(last_info.job.span, last_info.frame.tagged_key.description(tcx), depth)
111113
}
112114

113115
/// A resumable waiter of a query. The usize is the index into waiters in the query's latch

compiler/rustc_query_impl/src/plumbing.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ use crate::{
3636

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

4141
let suggested_limit = match tcx.recursion_limit() {
4242
Limit(0) => Limit(2),
4343
limit => limit * 2,
4444
};
4545

46-
tcx.sess.dcx().emit_fatal(QueryOverflow {
47-
span: info.job.span,
48-
note: QueryOverflowNote { desc: info.frame.tagged_key.description(tcx), depth },
46+
tcx.dcx().emit_fatal(QueryOverflow {
47+
span,
48+
note: QueryOverflowNote { desc, depth },
4949
suggested_limit,
5050
crate_name: tcx.crate_name(LOCAL_CRATE),
5151
});

0 commit comments

Comments
 (0)