@@ -393,14 +393,16 @@ pub(super) struct TraversalContext {
393
393
worklist : VecDeque < BasicCoverageBlock > ,
394
394
}
395
395
396
- pub ( super ) struct TraverseCoverageGraphWithLoops {
396
+ pub ( super ) struct TraverseCoverageGraphWithLoops < ' a > {
397
+ basic_coverage_blocks : & ' a CoverageGraph ,
398
+
397
399
backedges : IndexVec < BasicCoverageBlock , Vec < BasicCoverageBlock > > ,
398
400
context_stack : Vec < TraversalContext > ,
399
401
visited : BitSet < BasicCoverageBlock > ,
400
402
}
401
403
402
- impl TraverseCoverageGraphWithLoops {
403
- pub fn new ( basic_coverage_blocks : & CoverageGraph ) -> Self {
404
+ impl < ' a > TraverseCoverageGraphWithLoops < ' a > {
405
+ pub ( super ) fn new ( basic_coverage_blocks : & ' a CoverageGraph ) -> Self {
404
406
let backedges = find_loop_backedges ( basic_coverage_blocks) ;
405
407
406
408
let worklist = VecDeque :: from ( [ basic_coverage_blocks. start_node ( ) ] ) ;
@@ -411,7 +413,7 @@ impl TraverseCoverageGraphWithLoops {
411
413
// of the stack as loops are entered, and popped off of the stack when a loop's worklist is
412
414
// exhausted.
413
415
let visited = BitSet :: new_empty ( basic_coverage_blocks. num_nodes ( ) ) ;
414
- Self { backedges, context_stack, visited }
416
+ Self { basic_coverage_blocks , backedges, context_stack, visited }
415
417
}
416
418
417
419
/// For each loop on the loop context stack (top-down), yields a list of BCBs
@@ -424,7 +426,7 @@ impl TraverseCoverageGraphWithLoops {
424
426
. map ( |( from_bcbs, _to_bcb) | from_bcbs. as_slice ( ) )
425
427
}
426
428
427
- pub fn next ( & mut self , basic_coverage_blocks : & CoverageGraph ) -> Option < BasicCoverageBlock > {
429
+ pub ( super ) fn next ( & mut self ) -> Option < BasicCoverageBlock > {
428
430
debug ! (
429
431
"TraverseCoverageGraphWithLoops::next - context_stack: {:?}" ,
430
432
self . context_stack. iter( ) . rev( ) . collect:: <Vec <_>>( )
@@ -445,7 +447,7 @@ impl TraverseCoverageGraphWithLoops {
445
447
worklist : VecDeque :: new ( ) ,
446
448
} ) ;
447
449
}
448
- self . extend_worklist ( basic_coverage_blocks , bcb) ;
450
+ self . extend_worklist ( bcb) ;
449
451
return Some ( bcb) ;
450
452
} else {
451
453
// Strip contexts with empty worklists from the top of the stack
@@ -456,11 +458,8 @@ impl TraverseCoverageGraphWithLoops {
456
458
None
457
459
}
458
460
459
- pub fn extend_worklist (
460
- & mut self ,
461
- basic_coverage_blocks : & CoverageGraph ,
462
- bcb : BasicCoverageBlock ,
463
- ) {
461
+ pub fn extend_worklist ( & mut self , bcb : BasicCoverageBlock ) {
462
+ let Self { basic_coverage_blocks, .. } = * self ;
464
463
let successors = & basic_coverage_blocks. successors [ bcb] ;
465
464
debug ! ( "{:?} has {} successors:" , bcb, successors. len( ) ) ;
466
465
for & successor in successors {
0 commit comments