@@ -45,7 +45,7 @@ use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LocalDefId};
4545use rustc_hir:: intravisit:: { self , Visitor } ;
4646use rustc_middle:: bug;
4747use rustc_middle:: dep_graph:: {
48- DepGraphQuery , DepKind , DepNode , DepNodeFilter , EdgeFilter , dep_kinds,
48+ DepKind , DepNode , DepNodeFilter , EdgeFilter , RetainedDepGraph , dep_kinds,
4949} ;
5050use rustc_middle:: hir:: nested_filter;
5151use rustc_middle:: ty:: TyCtxt ;
@@ -59,7 +59,7 @@ use crate::errors;
5959pub ( crate ) fn assert_dep_graph ( tcx : TyCtxt < ' _ > ) {
6060 tcx. dep_graph . with_ignore ( || {
6161 if tcx. sess . opts . unstable_opts . dump_dep_graph {
62- tcx. dep_graph . with_query ( dump_graph) ;
62+ tcx. dep_graph . with_retained_dep_graph ( dump_graph) ;
6363 }
6464
6565 if !tcx. sess . opts . unstable_opts . query_dep_graph {
@@ -186,7 +186,7 @@ fn check_paths<'tcx>(tcx: TyCtxt<'tcx>, if_this_changed: &Sources, then_this_wou
186186 }
187187 return ;
188188 }
189- tcx. dep_graph . with_query ( |query| {
189+ tcx. dep_graph . with_retained_dep_graph ( |query| {
190190 for & ( _, source_def_id, ref source_dep_node) in if_this_changed {
191191 let dependents = query. transitive_predecessors ( source_dep_node) ;
192192 for & ( target_span, ref target_pass, _, ref target_dep_node) in then_this_would_need {
@@ -204,21 +204,21 @@ fn check_paths<'tcx>(tcx: TyCtxt<'tcx>, if_this_changed: &Sources, then_this_wou
204204 } ) ;
205205}
206206
207- fn dump_graph ( query : & DepGraphQuery ) {
207+ fn dump_graph ( graph : & RetainedDepGraph ) {
208208 let path: String = env:: var ( "RUST_DEP_GRAPH" ) . unwrap_or_else ( |_| "dep_graph" . to_string ( ) ) ;
209209
210210 let nodes = match env:: var ( "RUST_DEP_GRAPH_FILTER" ) {
211211 Ok ( string) => {
212212 // Expect one of: "-> target", "source -> target", or "source ->".
213213 let edge_filter =
214214 EdgeFilter :: new ( & string) . unwrap_or_else ( |e| bug ! ( "invalid filter: {}" , e) ) ;
215- let sources = node_set ( query , & edge_filter. source ) ;
216- let targets = node_set ( query , & edge_filter. target ) ;
217- filter_nodes ( query , & sources, & targets)
215+ let sources = node_set ( graph , & edge_filter. source ) ;
216+ let targets = node_set ( graph , & edge_filter. target ) ;
217+ filter_nodes ( graph , & sources, & targets)
218218 }
219- Err ( _) => query . nodes ( ) . into_iter ( ) . map ( |n| n. kind ) . collect ( ) ,
219+ Err ( _) => graph . nodes ( ) . into_iter ( ) . map ( |n| n. kind ) . collect ( ) ,
220220 } ;
221- let edges = filter_edges ( query , & nodes) ;
221+ let edges = filter_edges ( graph , & nodes) ;
222222
223223 {
224224 // dump a .txt file with just the edges:
@@ -281,51 +281,51 @@ impl<'a> dot::Labeller<'a> for GraphvizDepGraph {
281281// Given an optional filter like `"x,y,z"`, returns either `None` (no
282282// filter) or the set of nodes whose labels contain all of those
283283// substrings.
284- fn node_set < ' q > (
285- query : & ' q DepGraphQuery ,
284+ fn node_set < ' g > (
285+ graph : & ' g RetainedDepGraph ,
286286 filter : & DepNodeFilter ,
287- ) -> Option < FxIndexSet < & ' q DepNode > > {
287+ ) -> Option < FxIndexSet < & ' g DepNode > > {
288288 debug ! ( "node_set(filter={:?})" , filter) ;
289289
290290 if filter. accepts_all ( ) {
291291 return None ;
292292 }
293293
294- Some ( query . nodes ( ) . into_iter ( ) . filter ( |n| filter. test ( n) ) . collect ( ) )
294+ Some ( graph . nodes ( ) . into_iter ( ) . filter ( |n| filter. test ( n) ) . collect ( ) )
295295}
296296
297- fn filter_nodes < ' q > (
298- query : & ' q DepGraphQuery ,
299- sources : & Option < FxIndexSet < & ' q DepNode > > ,
300- targets : & Option < FxIndexSet < & ' q DepNode > > ,
297+ fn filter_nodes < ' g > (
298+ graph : & ' g RetainedDepGraph ,
299+ sources : & Option < FxIndexSet < & ' g DepNode > > ,
300+ targets : & Option < FxIndexSet < & ' g DepNode > > ,
301301) -> FxIndexSet < DepKind > {
302302 if let Some ( sources) = sources {
303303 if let Some ( targets) = targets {
304- walk_between ( query , sources, targets)
304+ walk_between ( graph , sources, targets)
305305 } else {
306- walk_nodes ( query , sources, OUTGOING )
306+ walk_nodes ( graph , sources, OUTGOING )
307307 }
308308 } else if let Some ( targets) = targets {
309- walk_nodes ( query , targets, INCOMING )
309+ walk_nodes ( graph , targets, INCOMING )
310310 } else {
311- query . nodes ( ) . into_iter ( ) . map ( |n| n. kind ) . collect ( )
311+ graph . nodes ( ) . into_iter ( ) . map ( |n| n. kind ) . collect ( )
312312 }
313313}
314314
315- fn walk_nodes < ' q > (
316- query : & ' q DepGraphQuery ,
317- starts : & FxIndexSet < & ' q DepNode > ,
315+ fn walk_nodes < ' g > (
316+ graph : & ' g RetainedDepGraph ,
317+ starts : & FxIndexSet < & ' g DepNode > ,
318318 direction : Direction ,
319319) -> FxIndexSet < DepKind > {
320320 let mut set = FxIndexSet :: default ( ) ;
321321 for & start in starts {
322322 debug ! ( "walk_nodes: start={:?} outgoing?={:?}" , start, direction == OUTGOING ) ;
323323 if set. insert ( start. kind ) {
324- let mut stack = vec ! [ query . indices[ start] ] ;
324+ let mut stack = vec ! [ graph . indices[ start] ] ;
325325 while let Some ( index) = stack. pop ( ) {
326- for ( _, edge) in query . graph . adjacent_edges ( index, direction) {
326+ for ( _, edge) in graph. inner . adjacent_edges ( index, direction) {
327327 let neighbor_index = edge. source_or_target ( direction) ;
328- let neighbor = query . graph . node_data ( neighbor_index) ;
328+ let neighbor = graph. inner . node_data ( neighbor_index) ;
329329 if set. insert ( neighbor. kind ) {
330330 stack. push ( neighbor_index) ;
331331 }
@@ -336,10 +336,10 @@ fn walk_nodes<'q>(
336336 set
337337}
338338
339- fn walk_between < ' q > (
340- query : & ' q DepGraphQuery ,
341- sources : & FxIndexSet < & ' q DepNode > ,
342- targets : & FxIndexSet < & ' q DepNode > ,
339+ fn walk_between < ' g > (
340+ graph : & ' g RetainedDepGraph ,
341+ sources : & FxIndexSet < & ' g DepNode > ,
342+ targets : & FxIndexSet < & ' g DepNode > ,
343343) -> FxIndexSet < DepKind > {
344344 // This is a bit tricky. We want to include a node only if it is:
345345 // (a) reachable from a source and (b) will reach a target. And we
@@ -354,27 +354,27 @@ fn walk_between<'q>(
354354 Excluded ,
355355 }
356356
357- let mut node_states = vec ! [ State :: Undecided ; query . graph. len_nodes( ) ] ;
357+ let mut node_states = vec ! [ State :: Undecided ; graph. inner . len_nodes( ) ] ;
358358
359359 for & target in targets {
360- node_states[ query . indices [ target] . 0 ] = State :: Included ;
360+ node_states[ graph . indices [ target] . 0 ] = State :: Included ;
361361 }
362362
363- for source in sources. iter ( ) . map ( |& n| query . indices [ n] ) {
364- recurse ( query , & mut node_states, source) ;
363+ for source in sources. iter ( ) . map ( |& n| graph . indices [ n] ) {
364+ recurse ( graph , & mut node_states, source) ;
365365 }
366366
367- return query
367+ return graph
368368 . nodes ( )
369369 . into_iter ( )
370370 . filter ( |& n| {
371- let index = query . indices [ n] ;
371+ let index = graph . indices [ n] ;
372372 node_states[ index. 0 ] == State :: Included
373373 } )
374374 . map ( |n| n. kind )
375375 . collect ( ) ;
376376
377- fn recurse ( query : & DepGraphQuery , node_states : & mut [ State ] , node : NodeIndex ) -> bool {
377+ fn recurse ( graph : & RetainedDepGraph , node_states : & mut [ State ] , node : NodeIndex ) -> bool {
378378 match node_states[ node. 0 ] {
379379 // known to reach a target
380380 State :: Included => return true ,
@@ -390,8 +390,8 @@ fn walk_between<'q>(
390390
391391 node_states[ node. 0 ] = State :: Deciding ;
392392
393- for neighbor_index in query . graph . successor_nodes ( node) {
394- if recurse ( query , node_states, neighbor_index) {
393+ for neighbor_index in graph. inner . successor_nodes ( node) {
394+ if recurse ( graph , node_states, neighbor_index) {
395395 node_states[ node. 0 ] = State :: Included ;
396396 }
397397 }
@@ -407,8 +407,8 @@ fn walk_between<'q>(
407407 }
408408}
409409
410- fn filter_edges ( query : & DepGraphQuery , nodes : & FxIndexSet < DepKind > ) -> Vec < ( DepKind , DepKind ) > {
411- let uniq: FxIndexSet < _ > = query
410+ fn filter_edges ( graph : & RetainedDepGraph , nodes : & FxIndexSet < DepKind > ) -> Vec < ( DepKind , DepKind ) > {
411+ let uniq: FxIndexSet < _ > = graph
412412 . edges ( )
413413 . into_iter ( )
414414 . map ( |( s, t) | ( s. kind , t. kind ) )
0 commit comments