@@ -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 , SourceScope , 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
}
@@ -102,7 +106,10 @@ impl BranchInfoBuilder {
102
106
let true_marker = self . inject_block_marker ( cfg, source_info, then_block) ;
103
107
let false_marker = self . inject_block_marker ( cfg, source_info, else_block) ;
104
108
105
- self . branch_spans . push ( BranchSpan { span, true_marker, false_marker } ) ;
109
+ self . branch_arm_lists . push ( vec ! [
110
+ BranchArm { span, marker: true_marker } ,
111
+ BranchArm { span, marker: false_marker } ,
112
+ ] ) ;
106
113
}
107
114
108
115
fn next_block_marker_id ( & mut self ) -> BlockMarkerId {
@@ -129,20 +136,20 @@ impl BranchInfoBuilder {
129
136
}
130
137
131
138
pub ( crate ) fn into_done ( self ) -> Option < Box < mir:: coverage:: BranchInfo > > {
132
- let Self { nots : _, num_block_markers, branch_spans } = self ;
139
+ let Self { nots : _, num_block_markers, branch_arm_lists } = self ;
133
140
134
141
if num_block_markers == 0 {
135
- assert ! ( branch_spans . is_empty( ) ) ;
142
+ assert ! ( branch_arm_lists . is_empty( ) ) ;
136
143
return None ;
137
144
}
138
145
139
- Some ( Box :: new ( mir:: coverage:: BranchInfo { num_block_markers, branch_spans } ) )
146
+ Some ( Box :: new ( mir:: coverage:: BranchInfo { num_block_markers, branch_arm_lists } ) )
140
147
}
141
148
}
142
149
143
150
impl Builder < ' _ , ' _ > {
144
151
/// If branch coverage is enabled, inject marker statements into `then_block`
145
- /// and `else_block`, and record their IDs in the table of branch spans .
152
+ /// and `else_block`, and record their IDs in the table of branches .
146
153
pub ( crate ) fn visit_coverage_branch_condition (
147
154
& mut self ,
148
155
expr_id : ExprId ,
0 commit comments