@@ -145,7 +145,7 @@ impl DepGraph {
145145 if let Some ( ..) = self . data {
146146 ty:: tls:: with_context_opt ( |icx| {
147147 let icx = if let Some ( icx) = icx { icx } else { return } ;
148- match * icx. task . lock ( ) {
148+ match * icx. task {
149149 OpenTask :: Ignore => {
150150 // ignored
151151 }
@@ -160,7 +160,7 @@ impl DepGraph {
160160 {
161161 ty:: tls:: with_context ( |icx| {
162162 let icx = ty:: tls:: ImplicitCtxt {
163- task : & Lock :: new ( OpenTask :: Ignore ) ,
163+ task : & OpenTask :: Ignore ,
164164 ..icx. clone ( )
165165 } ;
166166
@@ -207,11 +207,11 @@ impl DepGraph {
207207 R : HashStable < StableHashingContext < ' gcx > > ,
208208 {
209209 self . with_task_impl ( key, cx, arg, false , task,
210- |key| OpenTask :: Regular {
210+ |key| OpenTask :: Regular ( Lock :: new ( RegularOpenTask {
211211 node : key,
212212 reads : Vec :: new ( ) ,
213213 read_set : FxHashSet ( ) ,
214- } ,
214+ } ) ) ,
215215 |data, key, task| data. borrow_mut ( ) . complete_task ( key, task) )
216216 }
217217
@@ -263,24 +263,18 @@ impl DepGraph {
263263 profq_msg ( hcx. sess ( ) , ProfileQueriesMsg :: TaskBegin ( key. clone ( ) ) )
264264 } ;
265265
266- let ( result, open_task ) = if no_tcx {
267- ( task ( cx, arg) , open_task )
266+ let result = if no_tcx {
267+ task ( cx, arg)
268268 } else {
269269 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 ( )
281273 } ;
282274
283- ( r, open_task. into_inner ( ) )
275+ ty:: tls:: enter_context ( & icx, |_| {
276+ task ( cx, arg)
277+ } )
284278 } )
285279 } ;
286280
@@ -358,10 +352,10 @@ impl DepGraph {
358352 {
359353 if let Some ( ref data) = self . data {
360354 let ( result, open_task) = ty:: tls:: with_context ( |icx| {
361- let task = Lock :: new ( OpenTask :: Anon {
355+ let task = OpenTask :: Anon ( Lock :: new ( AnonOpenTask {
362356 reads : Vec :: new ( ) ,
363357 read_set : FxHashSet ( ) ,
364- } ) ;
358+ } ) ) ;
365359
366360 let r = {
367361 let icx = ty:: tls:: ImplicitCtxt {
@@ -374,7 +368,7 @@ impl DepGraph {
374368 } )
375369 } ;
376370
377- ( r, task. into_inner ( ) )
371+ ( r, task)
378372 } ) ;
379373 let dep_node_index = data. current
380374 . borrow_mut ( )
@@ -986,11 +980,12 @@ impl CurrentDepGraph {
986980 }
987981
988982 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 ( ) ;
994989 assert_eq ! ( node, key) ;
995990
996991 // If this is an input node, we expect that it either has no
@@ -1022,10 +1017,11 @@ impl CurrentDepGraph {
10221017 }
10231018
10241019 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 ( ) ;
10291025 debug_assert ! ( !kind. is_input( ) ) ;
10301026
10311027 let mut fingerprint = self . anon_id_seed ;
@@ -1074,18 +1070,16 @@ impl CurrentDepGraph {
10741070 fn read_index ( & mut self , source : DepNodeIndex ) {
10751071 ty:: tls:: with_context_opt ( |icx| {
10761072 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 ( ) ;
10831076 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) ;
10861079
10871080 if cfg ! ( debug_assertions) {
10881081 if let Some ( ref forbidden_edge) = self . forbidden_edge {
1082+ let target = & task. node ;
10891083 let source = self . nodes [ source] ;
10901084 if forbidden_edge. test ( & source, & target) {
10911085 bug ! ( "forbidden edge {:?} -> {:?} created" ,
@@ -1098,12 +1092,10 @@ impl CurrentDepGraph {
10981092 self . total_duplicate_read_count += 1 ;
10991093 }
11001094 }
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) ;
11071099 }
11081100 }
11091101 OpenTask :: Ignore | OpenTask :: EvalAlways { .. } => {
@@ -1128,17 +1120,20 @@ impl CurrentDepGraph {
11281120 }
11291121}
11301122
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+
11321134pub 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 > ) ,
11421137 Ignore ,
11431138 EvalAlways {
11441139 node : DepNode ,
0 commit comments