Auto merge of #133828 - compiler-errors:incr-sad, r= · rust-lang/rust@780efa9 (original) (raw)

File tree

5 files changed

lines changed

5 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -302,7 +302,11 @@ impl<D: Deps> DepGraph {
302 302 OP: FnOnce() -> R,
303 303 {
304 304 match self.data() {
305 -Some(data) => data.with_anon_task(cx, dep_kind, op),
305 +Some(data) => {
306 +let (result, index) = data.with_anon_task_inner(cx, dep_kind, op);
307 +self.read_index(index);
308 +(result, index)
309 +}
306 310 None => (op(), self.next_virtual_depnode_index()),
307 311 }
308 312 }
@@ -397,7 +401,7 @@ impl<D: Deps> DepGraphData {
397 401
398 402 /// Executes something within an "anonymous" task, that is, a task the
399 403 /// `DepNode` of which is determined by the list of inputs it read from.
400 - pub(crate) fn with_anon_task<Tcx: DepContext<Deps = D>, OP, R>(
404 + pub(crate) fn with_anon_task_inner<Tcx: DepContext<Deps = D>, OP, R>(
401 405 &self,
402 406 cx: Tcx,
403 407 dep_kind: DepKind,
Original file line number Diff line number Diff line change
@@ -520,9 +520,11 @@ where
520 520 let (result, dep_node_index) =
521 521 qcx.start_query(job_id, query.depth_limit(), Some(&diagnostics), |
522 522 if query.anon() {
523 -return dep_graph_data.with_anon_task(*qcx.dep_context(), query.dep_kind(), |
524 - query.compute(qcx, key)
525 -});
523 +return dep_graph_data.with_anon_task_inner(
524 +*qcx.dep_context(),
525 + query.dep_kind(),
526 + |
527 +);
526 528 }
527 529
528 530 // `to_dep_node` is expensive for some `DepKind`s.
Original file line number Diff line number Diff line change
@@ -1400,10 +1400,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1400 1400 where
1401 1401 OP: FnOnce(&mut Self) -> R,
1402 1402 {
1403 -let (result, dep_node) =
1404 -self.tcx().dep_graph.with_anon_task(self.tcx(), dep_kinds::TraitSelect, |
1405 -self.tcx().dep_graph.read_index(dep_node);
1406 -(result, dep_node)
1403 +self.tcx().dep_graph.with_anon_task(self.tcx(), dep_kinds::TraitSelect, |
1407 1404 }
1408 1405
1409 1406 /// filter_impls filters candidates that have a positive impl for a negative
Original file line number Diff line number Diff line change
@@ -511,7 +511,7 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph {
511 511
512 512 // This is for global caching, so we properly track query dependencies.
513 513 // Everything that affects the `result` should be performed within this
514 -// `with_anon_task` closure. If computing this goal depends on something
514 +// `with_cached_task` closure. If computing this goal depends on something
515 515 // not tracked by the cache key and from outside of this anon task, it
516 516 // must not be added to the global cache. Notably, this is the case for
517 517 // trait solver cycles participants.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
1 +//@ revisions: cfail1 cfail2
2 +
3 +//@ compile-flags: -Znext-solver
4 +//@ check-pass
5 +
6 +pub trait Future {
7 +type Error;
8 +fn poll() -> Self::Error;
9 +}
10 +
11 +struct S;
12 +impl Future for S {
13 +type Error = Error;
14 +fn poll() -> Self::Error {
15 +todo!()
16 +}
17 +}
18 +
19 +#[cfg(cfail1)]
20 +pub struct Error(());
21 +
22 +#[cfg(cfail2)]
23 +pub struct Error();
24 +
25 +fn main() {}