about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/mir/coverage.rs
diff options
context:
space:
mode:
authorZalathar <Zalathar@users.noreply.github.com>2023-08-31 16:03:12 +1000
committerZalathar <Zalathar@users.noreply.github.com>2023-10-18 21:23:58 +1100
commit79f935b96c2447c979124628187125a9e381e9dc (patch)
tree51a2db55f12bcf106cc6bf8b25240549046cac7a /compiler/rustc_middle/src/mir/coverage.rs
parenta18c5f3b751dbfa6c192dc48a6c6f28250e9bc97 (diff)
downloadrust-79f935b96c2447c979124628187125a9e381e9dc.tar.gz
rust-79f935b96c2447c979124628187125a9e381e9dc.zip
coverage: Rename `Operand` to `CovTerm`
Later patches in this PR will use `CovTerm` to represent things that are not
expression operands.
Diffstat (limited to 'compiler/rustc_middle/src/mir/coverage.rs')
-rw-r--r--compiler/rustc_middle/src/mir/coverage.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/compiler/rustc_middle/src/mir/coverage.rs b/compiler/rustc_middle/src/mir/coverage.rs
index 837331a2de8..fbb7f33a983 100644
--- a/compiler/rustc_middle/src/mir/coverage.rs
+++ b/compiler/rustc_middle/src/mir/coverage.rs
@@ -35,19 +35,21 @@ impl ExpressionId {
     pub const START: Self = Self::from_u32(0);
 }
 
-/// Operand of a coverage-counter expression.
+/// Enum that can hold a constant zero value, the ID of an physical coverage
+/// counter, or the ID of a coverage-counter expression.
 ///
-/// Operands can be a constant zero value, an actual coverage counter, or another
-/// expression. Counter/expression operands are referred to by ID.
+/// This was originally only used for expression operands (and named `Operand`),
+/// but the zero/counter/expression distinction is also useful for representing
+/// the value of code/gap mappings, and the true/false arms of branch mappings.
 #[derive(Copy, Clone, PartialEq, Eq)]
 #[derive(TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)]
-pub enum Operand {
+pub enum CovTerm {
     Zero,
     Counter(CounterId),
     Expression(ExpressionId),
 }
 
-impl Debug for Operand {
+impl Debug for CovTerm {
     fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
         match self {
             Self::Zero => write!(f, "Zero"),
@@ -68,9 +70,9 @@ pub enum CoverageKind {
         /// ID of this coverage-counter expression within its enclosing function.
         /// Other expressions in the same function can refer to it as an operand.
         id: ExpressionId,
-        lhs: Operand,
+        lhs: CovTerm,
         op: Op,
-        rhs: Operand,
+        rhs: CovTerm,
     },
     Unreachable,
 }