Skip to content

Commit c9384e5

Browse files
committed
coverage: Inline the "recursive" worker methods for assigning counters
Now that we don't manually pass around indent levels, there's no need for these worker methods to exist separately from their main callers.
1 parent 8c649ab commit c9384e5

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

compiler/rustc_mir_transform/src/coverage/counters.rs

+5-21
Original file line numberDiff line numberDiff line change
@@ -344,15 +344,8 @@ impl<'a> MakeBcbCounters<'a> {
344344
Ok(())
345345
}
346346

347-
fn get_or_make_counter_operand(&mut self, bcb: BasicCoverageBlock) -> Result<CovTerm, Error> {
348-
self.recursive_get_or_make_counter_operand(bcb)
349-
}
350-
351347
#[instrument(level = "debug", skip(self))]
352-
fn recursive_get_or_make_counter_operand(
353-
&mut self,
354-
bcb: BasicCoverageBlock,
355-
) -> Result<CovTerm, Error> {
348+
fn get_or_make_counter_operand(&mut self, bcb: BasicCoverageBlock) -> Result<CovTerm, Error> {
356349
// If the BCB already has a counter, return it.
357350
if let Some(counter_kind) = &self.coverage_counters.bcb_counters[bcb] {
358351
debug!("{bcb:?} already has a counter: {counter_kind:?}");
@@ -384,11 +377,10 @@ impl<'a> MakeBcbCounters<'a> {
384377
let mut predecessors = self.bcb_predecessors(bcb).to_owned().into_iter();
385378
debug!("{bcb:?} has multiple incoming edges and will need a sum-up expression");
386379
let first_edge_counter_operand =
387-
self.recursive_get_or_make_edge_counter_operand(predecessors.next().unwrap(), bcb)?;
380+
self.get_or_make_edge_counter_operand(predecessors.next().unwrap(), bcb)?;
388381
let mut some_sumup_edge_counter_operand = None;
389382
for predecessor in predecessors {
390-
let edge_counter_operand =
391-
self.recursive_get_or_make_edge_counter_operand(predecessor, bcb)?;
383+
let edge_counter_operand = self.get_or_make_edge_counter_operand(predecessor, bcb)?;
392384
if let Some(sumup_edge_counter_operand) =
393385
some_sumup_edge_counter_operand.replace(edge_counter_operand)
394386
{
@@ -411,16 +403,8 @@ impl<'a> MakeBcbCounters<'a> {
411403
self.coverage_counters.set_bcb_counter(bcb, counter_kind)
412404
}
413405

414-
fn get_or_make_edge_counter_operand(
415-
&mut self,
416-
from_bcb: BasicCoverageBlock,
417-
to_bcb: BasicCoverageBlock,
418-
) -> Result<CovTerm, Error> {
419-
self.recursive_get_or_make_edge_counter_operand(from_bcb, to_bcb)
420-
}
421-
422406
#[instrument(level = "debug", skip(self))]
423-
fn recursive_get_or_make_edge_counter_operand(
407+
fn get_or_make_edge_counter_operand(
424408
&mut self,
425409
from_bcb: BasicCoverageBlock,
426410
to_bcb: BasicCoverageBlock,
@@ -429,7 +413,7 @@ impl<'a> MakeBcbCounters<'a> {
429413
// counter is unnecessary. Just get or make a counter for the source BCB.
430414
let successors = self.bcb_successors(from_bcb).iter();
431415
if successors.len() == 1 {
432-
return self.recursive_get_or_make_counter_operand(from_bcb);
416+
return self.get_or_make_counter_operand(from_bcb);
433417
}
434418

435419
// If the edge already has a counter, return it.

0 commit comments

Comments
 (0)