Skip to content

Commit 529a1a6

Browse files
committed
Cache layout_depth
1 parent 534d371 commit 529a1a6

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

src/librustc/ty/query/plumbing.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ pub(super) struct JobOwner<'a, 'tcx: 'a, Q: QueryDescription<'tcx> + 'a> {
9797
cache: &'a Lock<QueryCache<'tcx, Q>>,
9898
key: Q::Key,
9999
job: Lrc<QueryJob<'tcx>>,
100+
// FIXME: Remove ImplicitCtxt.layout_depth to get rid of this field
101+
layout_depth: usize,
100102
}
101103

102104
impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
@@ -145,6 +147,7 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
145147
cache,
146148
job: job.clone(),
147149
key: (*key).clone(),
150+
layout_depth: icx.layout_depth,
148151
};
149152
entry.insert(QueryResult::Started(job));
150153
TryGetJob::NotYetStarted(owner)
@@ -200,23 +203,17 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
200203
where
201204
F: for<'b> FnOnce(TyCtxt<'b, 'tcx, 'lcx>) -> R
202205
{
203-
// The TyCtxt stored in TLS has the same global interner lifetime
204-
// as `tcx`, so we use `with_related_context` to relate the 'gcx lifetimes
205-
// when accessing the ImplicitCtxt
206-
tls::with_related_context(tcx, move |current_icx| {
207-
// Update the ImplicitCtxt to point to our new query job
208-
let new_icx = tls::ImplicitCtxt {
209-
tcx,
210-
query: Some(self.job.clone()),
211-
// FIXME: Remove `layout_depth` to avoid accessing ImplicitCtxt here
212-
layout_depth: current_icx.layout_depth,
213-
task,
214-
};
206+
// Update the ImplicitCtxt to point to our new query job
207+
let new_icx = tls::ImplicitCtxt {
208+
tcx,
209+
query: Some(self.job.clone()),
210+
layout_depth: self.layout_depth,
211+
task,
212+
};
215213

216-
// Use the ImplicitCtxt while we execute the query
217-
tls::enter_context(&new_icx, |_| {
218-
compute(tcx)
219-
})
214+
// Use the ImplicitCtxt while we execute the query
215+
tls::enter_context(&new_icx, |_| {
216+
compute(tcx)
220217
})
221218
}
222219
}

0 commit comments

Comments
 (0)