未验证 提交 f4193346 编写于 作者: M Mara Bos 提交者: GitHub

Rollup merge of #88567 - camelid:query-job-info, r=cjgillot

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.
...@@ -61,7 +61,7 @@ pub fn new(job: QueryShardJobId, shard: usize, kind: D) -> Self { ...@@ -61,7 +61,7 @@ pub fn new(job: QueryShardJobId, shard: usize, kind: D) -> Self {
} }
fn query(self, map: &QueryMap<D>) -> QueryStackFrame { fn query(self, map: &QueryMap<D>) -> QueryStackFrame {
map.get(&self).unwrap().info.query.clone() map.get(&self).unwrap().query.clone()
} }
#[cfg(parallel_compiler)] #[cfg(parallel_compiler)]
...@@ -81,7 +81,7 @@ fn latch<'a>(self, map: &'a QueryMap<D>) -> Option<&'a QueryLatch<D>> { ...@@ -81,7 +81,7 @@ fn latch<'a>(self, map: &'a QueryMap<D>) -> Option<&'a QueryLatch<D>> {
} }
pub struct QueryJobInfo<D> { pub struct QueryJobInfo<D> {
pub info: QueryInfo, pub query: QueryStackFrame,
pub job: QueryJob<D>, pub job: QueryJob<D>,
} }
...@@ -155,7 +155,7 @@ pub(super) fn find_cycle_in_stack( ...@@ -155,7 +155,7 @@ pub(super) fn find_cycle_in_stack(
while let Some(job) = current_job { while let Some(job) = current_job {
let info = query_map.get(&job).unwrap(); let info = query_map.get(&job).unwrap();
cycle.push(info.info.clone()); cycle.push(QueryInfo { span: info.job.span, query: info.query.clone() });
if job == *self { if job == *self {
cycle.reverse(); cycle.reverse();
...@@ -170,7 +170,7 @@ pub(super) fn find_cycle_in_stack( ...@@ -170,7 +170,7 @@ pub(super) fn find_cycle_in_stack(
.job .job
.parent .parent
.as_ref() .as_ref()
.map(|parent| (info.info.span, parent.query(&query_map))); .map(|parent| (info.job.span, parent.query(&query_map)));
return CycleError { usage, cycle }; return CycleError { usage, cycle };
} }
...@@ -649,13 +649,10 @@ pub fn print_query_stack<CTX: QueryContext>( ...@@ -649,13 +649,10 @@ pub fn print_query_stack<CTX: QueryContext>(
}; };
let mut diag = Diagnostic::new( let mut diag = Diagnostic::new(
Level::FailureNote, Level::FailureNote,
&format!( &format!("#{} [{}] {}", i, query_info.query.name, query_info.query.description),
"#{} [{}] {}",
i, query_info.info.query.name, query_info.info.query.description
),
); );
diag.span = diag.span =
tcx.dep_context().sess().source_map().guess_head_span(query_info.info.span).into(); tcx.dep_context().sess().source_map().guess_head_span(query_info.job.span).into();
handler.force_print_diagnostic(diag); handler.force_print_diagnostic(diag);
current_query = query_info.job.parent; current_query = query_info.job.parent;
......
...@@ -130,8 +130,8 @@ pub fn try_collect_active_jobs<CTX: Copy>( ...@@ -130,8 +130,8 @@ pub fn try_collect_active_jobs<CTX: Copy>(
for (k, v) in shard.active.iter() { for (k, v) in shard.active.iter() {
if let QueryResult::Started(ref job) = *v { if let QueryResult::Started(ref job) = *v {
let id = QueryJobId::new(job.id, shard_id, kind); let id = QueryJobId::new(job.id, shard_id, kind);
let info = QueryInfo { span: job.span, query: make_query(tcx, k.clone()) }; let query = make_query(tcx, k.clone());
jobs.insert(id, QueryJobInfo { info, job: job.clone() }); jobs.insert(id, QueryJobInfo { query, job: job.clone() });
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册