@@ -2,7 +2,7 @@ use std::assert_matches::assert_matches;
2
2
use std:: collections:: hash_map:: Entry ;
3
3
4
4
use rustc_data_structures:: fx:: FxHashMap ;
5
- use rustc_middle:: mir:: coverage:: { BlockMarkerId , BranchSpan , CoverageKind } ;
5
+ use rustc_middle:: mir:: coverage:: { BlockMarkerId , BranchArm , CoverageKind } ;
6
6
use rustc_middle:: mir:: { self , BasicBlock , SourceInfo , UnOp } ;
7
7
use rustc_middle:: thir:: { ExprId , ExprKind , Thir } ;
8
8
use rustc_middle:: ty:: TyCtxt ;
@@ -15,7 +15,7 @@ pub(crate) struct BranchInfoBuilder {
15
15
nots : FxHashMap < ExprId , NotInfo > ,
16
16
17
17
num_block_markers : usize ,
18
- branch_spans : Vec < BranchSpan > ,
18
+ branch_arm_lists : Vec < Vec < BranchArm > > ,
19
19
}
20
20
21
21
#[ derive( Clone , Copy ) ]
@@ -33,7 +33,11 @@ impl BranchInfoBuilder {
33
33
/// is enabled and `def_id` represents a function that is eligible for coverage.
34
34
pub ( crate ) fn new_if_enabled ( tcx : TyCtxt < ' _ > , def_id : LocalDefId ) -> Option < Self > {
35
35
if tcx. sess . instrument_coverage_branch ( ) && tcx. is_eligible_for_coverage ( def_id) {
36
- Some ( Self { nots : FxHashMap :: default ( ) , num_block_markers : 0 , branch_spans : vec ! [ ] } )
36
+ Some ( Self {
37
+ nots : FxHashMap :: default ( ) ,
38
+ num_block_markers : 0 ,
39
+ branch_arm_lists : vec ! [ ] ,
40
+ } )
37
41
} else {
38
42
None
39
43
}
@@ -89,7 +93,10 @@ impl BranchInfoBuilder {
89
93
let true_marker = self . inject_block_marker ( cfg, source_info, true_block) ;
90
94
let false_marker = self . inject_block_marker ( cfg, source_info, false_block) ;
91
95
92
- self . branch_spans . push ( BranchSpan { span : source_info. span , true_marker, false_marker } ) ;
96
+ self . branch_arm_lists . push ( vec ! [
97
+ BranchArm { span: source_info. span, marker: true_marker } ,
98
+ BranchArm { span: source_info. span, marker: false_marker } ,
99
+ ] ) ;
93
100
}
94
101
95
102
fn next_block_marker_id ( & mut self ) -> BlockMarkerId {
@@ -116,20 +123,20 @@ impl BranchInfoBuilder {
116
123
}
117
124
118
125
pub ( crate ) fn into_done ( self ) -> Option < Box < mir:: coverage:: BranchInfo > > {
119
- let Self { nots : _, num_block_markers, branch_spans } = self ;
126
+ let Self { nots : _, num_block_markers, branch_arm_lists } = self ;
120
127
121
128
if num_block_markers == 0 {
122
- assert ! ( branch_spans . is_empty( ) ) ;
129
+ assert ! ( branch_arm_lists . is_empty( ) ) ;
123
130
return None ;
124
131
}
125
132
126
- Some ( Box :: new ( mir:: coverage:: BranchInfo { num_block_markers, branch_spans } ) )
133
+ Some ( Box :: new ( mir:: coverage:: BranchInfo { num_block_markers, branch_arm_lists } ) )
127
134
}
128
135
}
129
136
130
137
impl Builder < ' _ , ' _ > {
131
138
/// If branch coverage is enabled, inject marker statements into `then_block`
132
- /// and `else_block`, and record their IDs in the table of branch spans .
139
+ /// and `else_block`, and record their IDs in the table of branches .
133
140
pub ( crate ) fn visit_coverage_branch_condition (
134
141
& mut self ,
135
142
mut expr_id : ExprId ,
0 commit comments