Skip to content

Commit 053c4f9

Browse files
committed
coverage: Remove next_id methods from counter/expression IDs
When these methods were originally written, I wasn't aware that `newtype_index!` already supports addition with ordinary numbers, without needing to unwrap and re-wrap.
1 parent b1cf0c8 commit 053c4f9

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

compiler/rustc_middle/src/mir/coverage.rs

-10
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ rustc_index::newtype_index! {
1818

1919
impl CounterId {
2020
pub const START: Self = Self::from_u32(0);
21-
22-
#[inline(always)]
23-
pub fn next_id(self) -> Self {
24-
Self::from_u32(self.as_u32() + 1)
25-
}
2621
}
2722

2823
rustc_index::newtype_index! {
@@ -38,11 +33,6 @@ rustc_index::newtype_index! {
3833

3934
impl ExpressionId {
4035
pub const START: Self = Self::from_u32(0);
41-
42-
#[inline(always)]
43-
pub fn next_id(self) -> Self {
44-
Self::from_u32(self.as_u32() + 1)
45-
}
4636
}
4737

4838
/// Operand of a coverage-counter expression.

compiler/rustc_mir_transform/src/coverage/counters.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,15 @@ impl CoverageCounters {
114114
/// Counter IDs start from one and go up.
115115
fn next_counter(&mut self) -> CounterId {
116116
let next = self.next_counter_id;
117-
self.next_counter_id = next.next_id();
117+
self.next_counter_id = self.next_counter_id + 1;
118118
next
119119
}
120120

121121
/// Expression IDs start from 0 and go up.
122122
/// (Counter IDs and Expression IDs are distinguished by the `Operand` enum.)
123123
fn next_expression(&mut self) -> ExpressionId {
124124
let next = self.next_expression_id;
125-
self.next_expression_id = next.next_id();
125+
self.next_expression_id = self.next_expression_id + 1;
126126
next
127127
}
128128

0 commit comments

Comments
 (0)