@@ -145,7 +145,7 @@ impl DepGraph {
145
145
if let Some ( ..) = self . data {
146
146
ty:: tls:: with_context_opt ( |icx| {
147
147
let icx = if let Some ( icx) = icx { icx } else { return } ;
148
- match * icx. task . lock ( ) {
148
+ match * icx. task {
149
149
OpenTask :: Ignore => {
150
150
// ignored
151
151
}
@@ -160,7 +160,7 @@ impl DepGraph {
160
160
{
161
161
ty:: tls:: with_context ( |icx| {
162
162
let icx = ty:: tls:: ImplicitCtxt {
163
- task : & Lock :: new ( OpenTask :: Ignore ) ,
163
+ task : & OpenTask :: Ignore ,
164
164
..icx. clone ( )
165
165
} ;
166
166
@@ -207,11 +207,11 @@ impl DepGraph {
207
207
R : HashStable < StableHashingContext < ' gcx > > ,
208
208
{
209
209
self . with_task_impl ( key, cx, arg, false , task,
210
- |key| OpenTask :: Regular {
210
+ |key| OpenTask :: Regular ( Lock :: new ( RegularOpenTask {
211
211
node : key,
212
212
reads : Vec :: new ( ) ,
213
213
read_set : FxHashSet ( ) ,
214
- } ,
214
+ } ) ) ,
215
215
|data, key, task| data. borrow_mut ( ) . complete_task ( key, task) )
216
216
}
217
217
@@ -263,24 +263,18 @@ impl DepGraph {
263
263
profq_msg ( hcx. sess ( ) , ProfileQueriesMsg :: TaskBegin ( key. clone ( ) ) )
264
264
} ;
265
265
266
- let ( result, open_task ) = if no_tcx {
267
- ( task ( cx, arg) , open_task )
266
+ let result = if no_tcx {
267
+ task ( cx, arg)
268
268
} else {
269
269
ty:: tls:: with_context ( |icx| {
270
- let open_task = Lock :: new ( open_task) ;
271
-
272
- let r = {
273
- let icx = ty:: tls:: ImplicitCtxt {
274
- task : & open_task,
275
- ..icx. clone ( )
276
- } ;
277
-
278
- ty:: tls:: enter_context ( & icx, |_| {
279
- task ( cx, arg)
280
- } )
270
+ let icx = ty:: tls:: ImplicitCtxt {
271
+ task : & open_task,
272
+ ..icx. clone ( )
281
273
} ;
282
274
283
- ( r, open_task. into_inner ( ) )
275
+ ty:: tls:: enter_context ( & icx, |_| {
276
+ task ( cx, arg)
277
+ } )
284
278
} )
285
279
} ;
286
280
@@ -358,10 +352,10 @@ impl DepGraph {
358
352
{
359
353
if let Some ( ref data) = self . data {
360
354
let ( result, open_task) = ty:: tls:: with_context ( |icx| {
361
- let task = Lock :: new ( OpenTask :: Anon {
355
+ let task = OpenTask :: Anon ( Lock :: new ( AnonOpenTask {
362
356
reads : Vec :: new ( ) ,
363
357
read_set : FxHashSet ( ) ,
364
- } ) ;
358
+ } ) ) ;
365
359
366
360
let r = {
367
361
let icx = ty:: tls:: ImplicitCtxt {
@@ -374,7 +368,7 @@ impl DepGraph {
374
368
} )
375
369
} ;
376
370
377
- ( r, task. into_inner ( ) )
371
+ ( r, task)
378
372
} ) ;
379
373
let dep_node_index = data. current
380
374
. borrow_mut ( )
@@ -986,11 +980,12 @@ impl CurrentDepGraph {
986
980
}
987
981
988
982
fn complete_task ( & mut self , key : DepNode , task : OpenTask ) -> DepNodeIndex {
989
- if let OpenTask :: Regular {
990
- node,
991
- read_set : _,
992
- reads
993
- } = task {
983
+ if let OpenTask :: Regular ( task) = task {
984
+ let RegularOpenTask {
985
+ node,
986
+ read_set : _,
987
+ reads
988
+ } = task. into_inner ( ) ;
994
989
assert_eq ! ( node, key) ;
995
990
996
991
// If this is an input node, we expect that it either has no
@@ -1022,10 +1017,11 @@ impl CurrentDepGraph {
1022
1017
}
1023
1018
1024
1019
fn pop_anon_task ( & mut self , kind : DepKind , task : OpenTask ) -> DepNodeIndex {
1025
- if let OpenTask :: Anon {
1026
- read_set : _,
1027
- reads
1028
- } = task {
1020
+ if let OpenTask :: Anon ( task) = task {
1021
+ let AnonOpenTask {
1022
+ read_set : _,
1023
+ reads
1024
+ } = task. into_inner ( ) ;
1029
1025
debug_assert ! ( !kind. is_input( ) ) ;
1030
1026
1031
1027
let mut fingerprint = self . anon_id_seed ;
@@ -1074,18 +1070,16 @@ impl CurrentDepGraph {
1074
1070
fn read_index ( & mut self , source : DepNodeIndex ) {
1075
1071
ty:: tls:: with_context_opt ( |icx| {
1076
1072
let icx = if let Some ( icx) = icx { icx } else { return } ;
1077
- match * icx. task . lock ( ) {
1078
- OpenTask :: Regular {
1079
- ref mut reads,
1080
- ref mut read_set,
1081
- node : ref target,
1082
- } => {
1073
+ match * icx. task {
1074
+ OpenTask :: Regular ( ref task) => {
1075
+ let mut task = task. lock ( ) ;
1083
1076
self . total_read_count += 1 ;
1084
- if read_set. insert ( source) {
1085
- reads. push ( source) ;
1077
+ if task . read_set . insert ( source) {
1078
+ task . reads . push ( source) ;
1086
1079
1087
1080
if cfg ! ( debug_assertions) {
1088
1081
if let Some ( ref forbidden_edge) = self . forbidden_edge {
1082
+ let target = & task. node ;
1089
1083
let source = self . nodes [ source] ;
1090
1084
if forbidden_edge. test ( & source, & target) {
1091
1085
bug ! ( "forbidden edge {:?} -> {:?} created" ,
@@ -1098,12 +1092,10 @@ impl CurrentDepGraph {
1098
1092
self . total_duplicate_read_count += 1 ;
1099
1093
}
1100
1094
}
1101
- OpenTask :: Anon {
1102
- ref mut reads,
1103
- ref mut read_set,
1104
- } => {
1105
- if read_set. insert ( source) {
1106
- reads. push ( source) ;
1095
+ OpenTask :: Anon ( ref task) => {
1096
+ let mut task = task. lock ( ) ;
1097
+ if task. read_set . insert ( source) {
1098
+ task. reads . push ( source) ;
1107
1099
}
1108
1100
}
1109
1101
OpenTask :: Ignore | OpenTask :: EvalAlways { .. } => {
@@ -1128,17 +1120,20 @@ impl CurrentDepGraph {
1128
1120
}
1129
1121
}
1130
1122
1131
- #[ derive( Clone , Debug , PartialEq ) ]
1123
+ pub struct RegularOpenTask {
1124
+ node : DepNode ,
1125
+ reads : Vec < DepNodeIndex > ,
1126
+ read_set : FxHashSet < DepNodeIndex > ,
1127
+ }
1128
+
1129
+ pub struct AnonOpenTask {
1130
+ reads : Vec < DepNodeIndex > ,
1131
+ read_set : FxHashSet < DepNodeIndex > ,
1132
+ }
1133
+
1132
1134
pub enum OpenTask {
1133
- Regular {
1134
- node : DepNode ,
1135
- reads : Vec < DepNodeIndex > ,
1136
- read_set : FxHashSet < DepNodeIndex > ,
1137
- } ,
1138
- Anon {
1139
- reads : Vec < DepNodeIndex > ,
1140
- read_set : FxHashSet < DepNodeIndex > ,
1141
- } ,
1135
+ Regular ( Lock < RegularOpenTask > ) ,
1136
+ Anon ( Lock < AnonOpenTask > ) ,
1142
1137
Ignore ,
1143
1138
EvalAlways {
1144
1139
node : DepNode ,
0 commit comments