From 2f1be08473e07e15d848b21e159be6729ffd90d2 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sun, 29 Oct 2023 20:53:17 +1100 Subject: [PATCH] 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. --- .../src/coverage/counters.rs | 26 ++++--------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/compiler/rustc_mir_transform/src/coverage/counters.rs b/compiler/rustc_mir_transform/src/coverage/counters.rs index 2e3e560975f0..8909de143335 100644 --- a/compiler/rustc_mir_transform/src/coverage/counters.rs +++ b/compiler/rustc_mir_transform/src/coverage/counters.rs @@ -344,15 +344,8 @@ impl<'a> MakeBcbCounters<'a> { Ok(()) } - fn get_or_make_counter_operand(&mut self, bcb: BasicCoverageBlock) -> Result { - self.recursive_get_or_make_counter_operand(bcb) - } - #[instrument(level = "debug", skip(self))] - fn recursive_get_or_make_counter_operand( - &mut self, - bcb: BasicCoverageBlock, - ) -> Result { + fn get_or_make_counter_operand(&mut self, bcb: BasicCoverageBlock) -> Result { // If the BCB already has a counter, return it. if let Some(counter_kind) = &self.coverage_counters.bcb_counters[bcb] { debug!("{bcb:?} already has a counter: {counter_kind:?}"); @@ -384,11 +377,10 @@ impl<'a> MakeBcbCounters<'a> { let mut predecessors = self.bcb_predecessors(bcb).to_owned().into_iter(); debug!("{bcb:?} has multiple incoming edges and will need a sum-up expression"); let first_edge_counter_operand = - self.recursive_get_or_make_edge_counter_operand(predecessors.next().unwrap(), bcb)?; + self.get_or_make_edge_counter_operand(predecessors.next().unwrap(), bcb)?; let mut some_sumup_edge_counter_operand = None; for predecessor in predecessors { - let edge_counter_operand = - self.recursive_get_or_make_edge_counter_operand(predecessor, bcb)?; + let edge_counter_operand = self.get_or_make_edge_counter_operand(predecessor, bcb)?; if let Some(sumup_edge_counter_operand) = some_sumup_edge_counter_operand.replace(edge_counter_operand) { @@ -411,16 +403,8 @@ impl<'a> MakeBcbCounters<'a> { self.coverage_counters.set_bcb_counter(bcb, counter_kind) } - fn get_or_make_edge_counter_operand( - &mut self, - from_bcb: BasicCoverageBlock, - to_bcb: BasicCoverageBlock, - ) -> Result { - self.recursive_get_or_make_edge_counter_operand(from_bcb, to_bcb) - } - #[instrument(level = "debug", skip(self))] - fn recursive_get_or_make_edge_counter_operand( + fn get_or_make_edge_counter_operand( &mut self, from_bcb: BasicCoverageBlock, to_bcb: BasicCoverageBlock, @@ -429,7 +413,7 @@ impl<'a> MakeBcbCounters<'a> { // counter is unnecessary. Just get or make a counter for the source BCB. let successors = self.bcb_successors(from_bcb).iter(); if successors.len() == 1 { - return self.recursive_get_or_make_counter_operand(from_bcb); + return self.get_or_make_counter_operand(from_bcb); } // If the edge already has a counter, return it.