Skip to content

Commit

Permalink
(> a49b2e8)move DecisionId into coverageinfo/mcdc.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhuUx committed Jul 16, 2024
1 parent 47ff2f5 commit c42a016
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
10 changes: 0 additions & 10 deletions compiler/rustc_middle/src/mir/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,6 @@ rustc_index::newtype_index! {
#[debug_format = "ExpressionId({})"]
pub struct ExpressionId {}
}

rustc_index::newtype_index! {
/// ID of a mcdc decision. Used to identify decision in a function.
#[derive(HashStable)]
#[encodable]
#[orderable]
#[debug_format = "DecisionId({})"]
pub struct DecisionId {}
}

rustc_index::newtype_index! {
/// ID of a mcdc condition. Used by llvm to check mcdc coverage.
///
Expand Down
7 changes: 5 additions & 2 deletions compiler/rustc_mir_build/src/build/coverageinfo/mcdc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::rc::Rc;
use rustc_data_structures::fx::FxIndexMap;
use rustc_middle::bug;
use rustc_middle::mir::coverage::{
BlockMarkerId, ConditionId, ConditionInfo, DecisionId, MCDCBranchSpan, MCDCDecisionSpan,
BlockMarkerId, ConditionId, ConditionInfo, MCDCBranchSpan, MCDCDecisionSpan,
};
use rustc_middle::mir::BasicBlock;
use rustc_middle::thir::{ExprKind, LogicalOp};
Expand All @@ -24,6 +24,9 @@ const MAX_CONDITIONS_IN_DECISION: usize = 6;
/// consuming excessive memory.
const MAX_DECISION_DEPTH: u16 = 0x3FFF;

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
struct DecisionId(usize);

#[derive(Debug)]
struct BooleanDecisionCtx {
id: DecisionId,
Expand Down Expand Up @@ -253,7 +256,7 @@ impl MCDCTargetInfo {
struct DecisionIdGen(usize);
impl DecisionIdGen {
fn next_decision_id(&mut self) -> DecisionId {
let id = DecisionId::from_usize(self.0);
let id = DecisionId(self.0);
self.0 += 1;
id
}
Expand Down

0 comments on commit c42a016

Please sign in to comment.