@@ -90,6 +90,10 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
9090 }
9191 return TryGetJob :: JobCompleted ( result) ;
9292 }
93+
94+ #[ cfg( parallel_compiler) ]
95+ let query_blocked_prof_timer;
96+
9397 let job = match lock. active . entry ( ( * key) . clone ( ) ) {
9498 Entry :: Occupied ( entry) => {
9599 match * entry. get ( ) {
@@ -98,7 +102,9 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
98102 // in another thread has completed. Record how long we wait in the
99103 // self-profiler.
100104 #[ cfg( parallel_compiler) ]
101- tcx. prof . query_blocked_start ( Q :: NAME ) ;
105+ {
106+ query_blocked_prof_timer = tcx. prof . query_blocked ( Q :: NAME ) ;
107+ }
102108
103109 job. clone ( )
104110 } ,
@@ -140,7 +146,11 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
140146 #[ cfg( parallel_compiler) ]
141147 {
142148 let result = job. r#await ( tcx, span) ;
143- tcx. prof . query_blocked_end ( Q :: NAME ) ;
149+
150+ // This `drop()` is not strictly necessary as the binding
151+ // would go out of scope anyway. But it's good to have an
152+ // explicit marker of how far the measurement goes.
153+ drop ( query_blocked_prof_timer) ;
144154
145155 if let Err ( cycle) = result {
146156 return TryGetJob :: Cycle ( Q :: handle_cycle_error ( tcx, cycle) ) ;
0 commit comments