Skip to content

Commit 4553a4b

Browse files
committed
Remove redundant Span in QueryJobInfo
Previously, `QueryJobInfo` was composed of two parts: a `QueryInfo` and a `QueryJob`. However, both `QueryInfo` and `QueryJob` have a `span` field, which seem to be the same. So, the `span` was recorded twice. Now, `QueryJobInfo` is composed of a `QueryStackFrame` (the other field of `QueryInfo`) and a `QueryJob`. So, now, the `span` is only recorded once.
1 parent ad3407f commit 4553a4b

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

compiler/rustc_query_system/src/query/job.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ where
6161
}
6262

6363
fn query(self, map: &QueryMap<D>) -> QueryStackFrame {
64-
map.get(&self).unwrap().info.query.clone()
64+
map.get(&self).unwrap().query.clone()
6565
}
6666

6767
#[cfg(parallel_compiler)]
@@ -81,7 +81,7 @@ where
8181
}
8282

8383
pub struct QueryJobInfo<D> {
84-
pub info: QueryInfo,
84+
pub query: QueryStackFrame,
8585
pub job: QueryJob<D>,
8686
}
8787

@@ -155,7 +155,7 @@ where
155155

156156
while let Some(job) = current_job {
157157
let info = query_map.get(&job).unwrap();
158-
cycle.push(info.info.clone());
158+
cycle.push(QueryInfo { span: info.job.span, query: info.query.clone() });
159159

160160
if job == *self {
161161
cycle.reverse();
@@ -170,7 +170,7 @@ where
170170
.job
171171
.parent
172172
.as_ref()
173-
.map(|parent| (info.info.span, parent.query(&query_map)));
173+
.map(|parent| (info.job.span, parent.query(&query_map)));
174174
return CycleError { usage, cycle };
175175
}
176176

@@ -649,13 +649,10 @@ pub fn print_query_stack<CTX: QueryContext>(
649649
};
650650
let mut diag = Diagnostic::new(
651651
Level::FailureNote,
652-
&format!(
653-
"#{} [{}] {}",
654-
i, query_info.info.query.name, query_info.info.query.description
655-
),
652+
&format!("#{} [{}] {}", i, query_info.query.name, query_info.query.description),
656653
);
657654
diag.span =
658-
tcx.dep_context().sess().source_map().guess_head_span(query_info.info.span).into();
655+
tcx.dep_context().sess().source_map().guess_head_span(query_info.job.span).into();
659656
handler.force_print_diagnostic(diag);
660657

661658
current_query = query_info.job.parent;

compiler/rustc_query_system/src/query/plumbing.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ where
130130
for (k, v) in shard.active.iter() {
131131
if let QueryResult::Started(ref job) = *v {
132132
let id = QueryJobId::new(job.id, shard_id, kind);
133-
let info = QueryInfo { span: job.span, query: make_query(tcx, k.clone()) };
134-
jobs.insert(id, QueryJobInfo { info, job: job.clone() });
133+
let query = make_query(tcx, k.clone());
134+
jobs.insert(id, QueryJobInfo { query, job: job.clone() });
135135
}
136136
}
137137
}

0 commit comments

Comments
 (0)