Skip to content

Commit

Permalink
coverage: Use variable name this in CoverageGraph::from_mir
Browse files Browse the repository at this point in the history
This makes it easier to see that we're manipulating the instance that is being
constructed, and is a lot less verbose than `basic_coverage_blocks`.
  • Loading branch information
Zalathar committed Feb 23, 2024
1 parent 397937d commit 9137c1e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions compiler/rustc_mir_transform/src/coverage/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,18 @@ impl CoverageGraph {
}
}

let mut basic_coverage_blocks =
Self { bcbs, bb_to_bcb, successors, predecessors, dominators: None };
let dominators = dominators::dominators(&basic_coverage_blocks);
basic_coverage_blocks.dominators = Some(dominators);
let mut this = Self { bcbs, bb_to_bcb, successors, predecessors, dominators: None };

this.dominators = Some(dominators::dominators(&this));

// The coverage graph's entry-point node (bcb0) always starts with bb0,
// which never has predecessors. Any other blocks merged into bcb0 can't
// have multiple (coverage-relevant) predecessors, so bcb0 always has
// zero in-edges.
assert!(basic_coverage_blocks[START_BCB].leader_bb() == mir::START_BLOCK);
assert!(basic_coverage_blocks.predecessors[START_BCB].is_empty());
assert!(this[START_BCB].leader_bb() == mir::START_BLOCK);
assert!(this.predecessors[START_BCB].is_empty());

basic_coverage_blocks
this
}

fn compute_basic_coverage_blocks(
Expand Down

0 comments on commit 9137c1e

Please sign in to comment.