@@ -44,7 +44,7 @@ use rustc_hir::attrs::AttributeKind;
4444use rustc_hir:: def_id:: { CRATE_DEF_ID , DefId , LocalDefId } ;
4545use rustc_hir:: intravisit:: { self , Visitor } ;
4646use rustc_middle:: bug;
47- use rustc_middle:: dep_graph:: { DepGraphQuery , DepKind , DepNode , DepNodeFilter , EdgeFilter } ;
47+ use rustc_middle:: dep_graph:: { DepKind , DepNode , DepNodeFilter , EdgeFilter , RetainedDepGraph } ;
4848use rustc_middle:: hir:: nested_filter;
4949use rustc_middle:: ty:: TyCtxt ;
5050use rustc_span:: { Span , Symbol , sym} ;
@@ -57,7 +57,7 @@ use crate::errors;
5757pub ( crate ) fn assert_dep_graph ( tcx : TyCtxt < ' _ > ) {
5858 tcx. dep_graph . with_ignore ( || {
5959 if tcx. sess . opts . unstable_opts . dump_dep_graph {
60- tcx. dep_graph . with_query ( dump_graph) ;
60+ tcx. dep_graph . with_retained_dep_graph ( dump_graph) ;
6161 }
6262
6363 if !tcx. sess . opts . unstable_opts . query_dep_graph {
@@ -184,7 +184,7 @@ fn check_paths<'tcx>(tcx: TyCtxt<'tcx>, if_this_changed: &Sources, then_this_wou
184184 }
185185 return ;
186186 }
187- tcx. dep_graph . with_query ( |query| {
187+ tcx. dep_graph . with_retained_dep_graph ( |query| {
188188 for & ( _, source_def_id, ref source_dep_node) in if_this_changed {
189189 let dependents = query. transitive_predecessors ( source_dep_node) ;
190190 for & ( target_span, ref target_pass, _, ref target_dep_node) in then_this_would_need {
@@ -202,21 +202,21 @@ fn check_paths<'tcx>(tcx: TyCtxt<'tcx>, if_this_changed: &Sources, then_this_wou
202202 } ) ;
203203}
204204
205- fn dump_graph ( query : & DepGraphQuery ) {
205+ fn dump_graph ( graph : & RetainedDepGraph ) {
206206 let path: String = env:: var ( "RUST_DEP_GRAPH" ) . unwrap_or_else ( |_| "dep_graph" . to_string ( ) ) ;
207207
208208 let nodes = match env:: var ( "RUST_DEP_GRAPH_FILTER" ) {
209209 Ok ( string) => {
210210 // Expect one of: "-> target", "source -> target", or "source ->".
211211 let edge_filter =
212212 EdgeFilter :: new ( & string) . unwrap_or_else ( |e| bug ! ( "invalid filter: {}" , e) ) ;
213- let sources = node_set ( query , & edge_filter. source ) ;
214- let targets = node_set ( query , & edge_filter. target ) ;
215- filter_nodes ( query , & sources, & targets)
213+ let sources = node_set ( graph , & edge_filter. source ) ;
214+ let targets = node_set ( graph , & edge_filter. target ) ;
215+ filter_nodes ( graph , & sources, & targets)
216216 }
217- Err ( _) => query . nodes ( ) . into_iter ( ) . map ( |n| n. kind ) . collect ( ) ,
217+ Err ( _) => graph . nodes ( ) . into_iter ( ) . map ( |n| n. kind ) . collect ( ) ,
218218 } ;
219- let edges = filter_edges ( query , & nodes) ;
219+ let edges = filter_edges ( graph , & nodes) ;
220220
221221 {
222222 // dump a .txt file with just the edges:
@@ -279,51 +279,51 @@ impl<'a> dot::Labeller<'a> for GraphvizDepGraph {
279279// Given an optional filter like `"x,y,z"`, returns either `None` (no
280280// filter) or the set of nodes whose labels contain all of those
281281// substrings.
282- fn node_set < ' q > (
283- query : & ' q DepGraphQuery ,
282+ fn node_set < ' g > (
283+ graph : & ' g RetainedDepGraph ,
284284 filter : & DepNodeFilter ,
285- ) -> Option < FxIndexSet < & ' q DepNode > > {
285+ ) -> Option < FxIndexSet < & ' g DepNode > > {
286286 debug ! ( "node_set(filter={:?})" , filter) ;
287287
288288 if filter. accepts_all ( ) {
289289 return None ;
290290 }
291291
292- Some ( query . nodes ( ) . into_iter ( ) . filter ( |n| filter. test ( n) ) . collect ( ) )
292+ Some ( graph . nodes ( ) . into_iter ( ) . filter ( |n| filter. test ( n) ) . collect ( ) )
293293}
294294
295- fn filter_nodes < ' q > (
296- query : & ' q DepGraphQuery ,
297- sources : & Option < FxIndexSet < & ' q DepNode > > ,
298- targets : & Option < FxIndexSet < & ' q DepNode > > ,
295+ fn filter_nodes < ' g > (
296+ graph : & ' g RetainedDepGraph ,
297+ sources : & Option < FxIndexSet < & ' g DepNode > > ,
298+ targets : & Option < FxIndexSet < & ' g DepNode > > ,
299299) -> FxIndexSet < DepKind > {
300300 if let Some ( sources) = sources {
301301 if let Some ( targets) = targets {
302- walk_between ( query , sources, targets)
302+ walk_between ( graph , sources, targets)
303303 } else {
304- walk_nodes ( query , sources, OUTGOING )
304+ walk_nodes ( graph , sources, OUTGOING )
305305 }
306306 } else if let Some ( targets) = targets {
307- walk_nodes ( query , targets, INCOMING )
307+ walk_nodes ( graph , targets, INCOMING )
308308 } else {
309- query . nodes ( ) . into_iter ( ) . map ( |n| n. kind ) . collect ( )
309+ graph . nodes ( ) . into_iter ( ) . map ( |n| n. kind ) . collect ( )
310310 }
311311}
312312
313- fn walk_nodes < ' q > (
314- query : & ' q DepGraphQuery ,
315- starts : & FxIndexSet < & ' q DepNode > ,
313+ fn walk_nodes < ' g > (
314+ graph : & ' g RetainedDepGraph ,
315+ starts : & FxIndexSet < & ' g DepNode > ,
316316 direction : Direction ,
317317) -> FxIndexSet < DepKind > {
318318 let mut set = FxIndexSet :: default ( ) ;
319319 for & start in starts {
320320 debug ! ( "walk_nodes: start={:?} outgoing?={:?}" , start, direction == OUTGOING ) ;
321321 if set. insert ( start. kind ) {
322- let mut stack = vec ! [ query . indices[ start] ] ;
322+ let mut stack = vec ! [ graph . indices[ start] ] ;
323323 while let Some ( index) = stack. pop ( ) {
324- for ( _, edge) in query . graph . adjacent_edges ( index, direction) {
324+ for ( _, edge) in graph. inner . adjacent_edges ( index, direction) {
325325 let neighbor_index = edge. source_or_target ( direction) ;
326- let neighbor = query . graph . node_data ( neighbor_index) ;
326+ let neighbor = graph. inner . node_data ( neighbor_index) ;
327327 if set. insert ( neighbor. kind ) {
328328 stack. push ( neighbor_index) ;
329329 }
@@ -334,10 +334,10 @@ fn walk_nodes<'q>(
334334 set
335335}
336336
337- fn walk_between < ' q > (
338- query : & ' q DepGraphQuery ,
339- sources : & FxIndexSet < & ' q DepNode > ,
340- targets : & FxIndexSet < & ' q DepNode > ,
337+ fn walk_between < ' g > (
338+ graph : & ' g RetainedDepGraph ,
339+ sources : & FxIndexSet < & ' g DepNode > ,
340+ targets : & FxIndexSet < & ' g DepNode > ,
341341) -> FxIndexSet < DepKind > {
342342 // This is a bit tricky. We want to include a node only if it is:
343343 // (a) reachable from a source and (b) will reach a target. And we
@@ -352,27 +352,27 @@ fn walk_between<'q>(
352352 Excluded ,
353353 }
354354
355- let mut node_states = vec ! [ State :: Undecided ; query . graph. len_nodes( ) ] ;
355+ let mut node_states = vec ! [ State :: Undecided ; graph. inner . len_nodes( ) ] ;
356356
357357 for & target in targets {
358- node_states[ query . indices [ target] . 0 ] = State :: Included ;
358+ node_states[ graph . indices [ target] . 0 ] = State :: Included ;
359359 }
360360
361- for source in sources. iter ( ) . map ( |& n| query . indices [ n] ) {
362- recurse ( query , & mut node_states, source) ;
361+ for source in sources. iter ( ) . map ( |& n| graph . indices [ n] ) {
362+ recurse ( graph , & mut node_states, source) ;
363363 }
364364
365- return query
365+ return graph
366366 . nodes ( )
367367 . into_iter ( )
368368 . filter ( |& n| {
369- let index = query . indices [ n] ;
369+ let index = graph . indices [ n] ;
370370 node_states[ index. 0 ] == State :: Included
371371 } )
372372 . map ( |n| n. kind )
373373 . collect ( ) ;
374374
375- fn recurse ( query : & DepGraphQuery , node_states : & mut [ State ] , node : NodeIndex ) -> bool {
375+ fn recurse ( graph : & RetainedDepGraph , node_states : & mut [ State ] , node : NodeIndex ) -> bool {
376376 match node_states[ node. 0 ] {
377377 // known to reach a target
378378 State :: Included => return true ,
@@ -388,8 +388,8 @@ fn walk_between<'q>(
388388
389389 node_states[ node. 0 ] = State :: Deciding ;
390390
391- for neighbor_index in query . graph . successor_nodes ( node) {
392- if recurse ( query , node_states, neighbor_index) {
391+ for neighbor_index in graph. inner . successor_nodes ( node) {
392+ if recurse ( graph , node_states, neighbor_index) {
393393 node_states[ node. 0 ] = State :: Included ;
394394 }
395395 }
@@ -405,8 +405,8 @@ fn walk_between<'q>(
405405 }
406406}
407407
408- fn filter_edges ( query : & DepGraphQuery , nodes : & FxIndexSet < DepKind > ) -> Vec < ( DepKind , DepKind ) > {
409- let uniq: FxIndexSet < _ > = query
408+ fn filter_edges ( graph : & RetainedDepGraph , nodes : & FxIndexSet < DepKind > ) -> Vec < ( DepKind , DepKind ) > {
409+ let uniq: FxIndexSet < _ > = graph
410410 . edges ( )
411411 . into_iter ( )
412412 . map ( |( s, t) | ( s. kind , t. kind ) )
0 commit comments