@@ -336,13 +336,17 @@ impl<D: Deps> DepGraphData<D> {
336336 // in `DepGraph::try_mark_green()`.
337337 // 2. Two distinct query keys get mapped to the same `DepNode`
338338 // (see for example #48923).
339- self . assert_dep_node_not_yet_allocated_in_current_session ( & key, || {
340- format ! (
341- "forcing query with already existing `DepNode`\n \
339+ self . assert_dep_node_not_yet_allocated_in_current_session (
340+ cx. dep_context ( ) . sess ( ) ,
341+ & key,
342+ || {
343+ format ! (
344+ "forcing query with already existing `DepNode`\n \
342345 - query-key: {arg:?}\n \
343346 - dep-node: {key:?}"
344- )
345- } ) ;
347+ )
348+ } ,
349+ ) ;
346350
347351 let with_deps = |task_deps| D :: with_deps ( task_deps, || task ( cx, arg) ) ;
348352 let ( result, edges) = if cx. dep_context ( ) . is_eval_always ( key. kind ) {
@@ -627,12 +631,20 @@ impl<D: Deps> DepGraph<D> {
627631impl < D : Deps > DepGraphData < D > {
628632 fn assert_dep_node_not_yet_allocated_in_current_session < S : std:: fmt:: Display > (
629633 & self ,
634+ sess : & Session ,
630635 dep_node : & DepNode ,
631636 msg : impl FnOnce ( ) -> S ,
632637 ) {
633638 if let Some ( prev_index) = self . previous . node_to_index_opt ( dep_node) {
634- let current = self . colors . get ( prev_index) ;
635- assert_matches ! ( current, DepNodeColor :: Unknown , "{}" , msg( ) )
639+ let color = self . colors . get ( prev_index) ;
640+ let ok = match color {
641+ DepNodeColor :: Unknown => true ,
642+ DepNodeColor :: Red => false ,
643+ DepNodeColor :: Green ( ..) => sess. threads ( ) > 1 , // Other threads may mark this green
644+ } ;
645+ if !ok {
646+ panic ! ( "{}" , msg( ) )
647+ }
636648 } else if let Some ( nodes_in_current_session) = & self . current . nodes_in_current_session {
637649 outline ( || {
638650 let seen = nodes_in_current_session. lock ( ) . contains_key ( dep_node) ;
@@ -1035,11 +1047,12 @@ impl<D: Deps> DepGraph<D> {
10351047
10361048 pub fn assert_dep_node_not_yet_allocated_in_current_session < S : std:: fmt:: Display > (
10371049 & self ,
1050+ sess : & Session ,
10381051 dep_node : & DepNode ,
10391052 msg : impl FnOnce ( ) -> S ,
10401053 ) {
10411054 if let Some ( data) = & self . data {
1042- data. assert_dep_node_not_yet_allocated_in_current_session ( dep_node, msg)
1055+ data. assert_dep_node_not_yet_allocated_in_current_session ( sess , dep_node, msg)
10431056 }
10441057 }
10451058
0 commit comments