Skip to content

Commit 1336fb0

Browse files
committed
wip
1 parent 8a1d1de commit 1336fb0

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/librustc/ty/maps/plumbing.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ macro_rules! profq_key {
9999
}
100100
}
101101

102+
/// A type representing the responsibility to execute the job in the `job` field.
103+
/// This will poison the relevant query if dropped.
102104
pub(super) struct JobOwner<'a, 'tcx: 'a, Q: QueryDescription<'tcx> + 'a> {
103105
map: &'a Lock<QueryMap<'tcx, Q>>,
104106
key: Q::Key,
@@ -165,6 +167,8 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
165167
}
166168
}
167169

170+
/// Completes the query by updating the query map with the `result`,
171+
/// signals the waiter and forgets the JobOwner, so it won't poison the query
168172
pub(super) fn complete(self, result: &Q::Value, dep_node_index: DepNodeIndex) {
169173
// We can move out of `self` here because we `mem::forget` it below
170174
let key = unsafe { ptr::read(&self.key) };
@@ -180,14 +184,14 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
180184
job.signal_complete();
181185
}
182186

183-
/// Creates a job for the query and updates the query map indicating that it started.
184-
/// Then it changes ImplicitCtxt to point to the new query job while it executes.
185-
/// If the query panics, this updates the query map to indicate so.
187+
/// Executes a job by changing the ImplicitCtxt to point to the
188+
/// new query job while it executes. It returns the diagnostics
189+
/// captured during execution and the actual result.
186190
pub(super) fn start<'lcx, F, R>(
187191
&self,
188192
tcx: TyCtxt<'_, 'tcx, 'lcx>,
189193
compute: F)
190-
-> Result<(R, Vec<Diagnostic>), CycleError<'tcx>>
194+
-> (R, Vec<Diagnostic>)
191195
where
192196
F: for<'b> FnOnce(TyCtxt<'b, 'tcx, 'lcx>) -> R
193197
{
@@ -538,7 +542,7 @@ macro_rules! define_maps {
538542
tcx.dep_graph.with_anon_task(dep_node.kind, || {
539543
Self::compute_result(tcx.global_tcx(), key)
540544
})
541-
})?;
545+
});
542546

543547
profq_msg!(tcx, ProfileQueriesMsg::ProviderEnd);
544548
let ((result, dep_node_index), diagnostics) = res;
@@ -649,7 +653,7 @@ macro_rules! define_maps {
649653
tcx.dep_graph.with_ignore(|| {
650654
Self::compute_result(tcx, key)
651655
})
652-
})?;
656+
});
653657
result
654658
};
655659

@@ -736,7 +740,7 @@ macro_rules! define_maps {
736740
key,
737741
Self::compute_result)
738742
}
739-
})?;
743+
});
740744
profq_msg!(tcx, ProfileQueriesMsg::ProviderEnd);
741745

742746
let ((result, dep_node_index), diagnostics) = res;

0 commit comments

Comments
 (0)