@@ -83,9 +83,12 @@ pub(crate) fn gather_active_jobs_inner<'tcx, K: Copy>(
8383 Some ( ( ) )
8484}
8585
86- /// A type representing the responsibility to execute the job in the `job` field.
87- /// This will poison the relevant query if dropped.
88- struct JobOwner < ' tcx , K >
86+ /// Guard object representing the responsibility to execute a query job and
87+ /// mark it as completed.
88+ ///
89+ /// This will poison the relevant query key if it is dropped without calling
90+ /// [`Self::complete`].
91+ struct ActiveJobGuard < ' tcx , K >
8992where
9093 K : Eq + Hash + Copy ,
9194{
@@ -137,12 +140,12 @@ fn handle_cycle_error<'tcx, C: QueryCache, const FLAGS: QueryFlags>(
137140 }
138141}
139142
140- impl < ' tcx , K > JobOwner < ' tcx , K >
143+ impl < ' tcx , K > ActiveJobGuard < ' tcx , K >
141144where
142145 K : Eq + Hash + Copy ,
143146{
144147 /// Completes the query by updating the query cache with the `result`,
145- /// signals the waiter and forgets the JobOwner, so it won't poison the query
148+ /// signals the waiter, and forgets the guard so it won't poison the query.
146149 fn complete < C > ( self , cache : & C , key_hash : u64 , result : C :: Value , dep_node_index : DepNodeIndex )
147150 where
148151 C : QueryCache < Key = K > ,
@@ -174,7 +177,7 @@ where
174177 }
175178}
176179
177- impl < ' tcx , K > Drop for JobOwner < ' tcx , K >
180+ impl < ' tcx , K > Drop for ActiveJobGuard < ' tcx , K >
178181where
179182 K : Eq + Hash + Copy ,
180183{
@@ -342,11 +345,13 @@ fn execute_job<'tcx, C: QueryCache, const FLAGS: QueryFlags, const INCR: bool>(
342345 id : QueryJobId ,
343346 dep_node : Option < DepNode > ,
344347) -> ( C :: Value , Option < DepNodeIndex > ) {
345- // Use `JobOwner` so the query will be poisoned if executing it panics.
346- let job_owner = JobOwner { state, key } ;
348+ // Set up a guard object that will automatically poison the query if a
349+ // panic occurs while executing the query (or any intermediate plumbing).
350+ let job_guard = ActiveJobGuard { state, key } ;
347351
348352 debug_assert_eq ! ( qcx. tcx. dep_graph. is_fully_enabled( ) , INCR ) ;
349353
354+ // Delegate to another function to actually execute the query job.
350355 let ( result, dep_node_index) = if INCR {
351356 execute_job_incr ( query, qcx, qcx. tcx . dep_graph . data ( ) . unwrap ( ) , key, dep_node, id)
352357 } else {
@@ -388,7 +393,9 @@ fn execute_job<'tcx, C: QueryCache, const FLAGS: QueryFlags, const INCR: bool>(
388393 }
389394 }
390395 }
391- job_owner. complete ( cache, key_hash, result, dep_node_index) ;
396+
397+ // Tell the guard to perform completion bookkeeping, and also to not poison the query.
398+ job_guard. complete ( cache, key_hash, result, dep_node_index) ;
392399
393400 ( result, Some ( dep_node_index) )
394401}
0 commit comments