@@ -3,70 +3,30 @@ use rustc_middle::mir::coverage::{
3
3
CovTerm , CoverageIdsInfo , Expression , FunctionCoverageInfo , Mapping , MappingKind , Op ,
4
4
SourceRegion ,
5
5
} ;
6
- use rustc_middle:: ty:: Instance ;
7
- use tracing:: debug;
8
6
9
7
use crate :: coverageinfo:: ffi:: { Counter , CounterExpression , ExprKind } ;
10
8
11
- /// Holds all of the coverage mapping data associated with a function instance,
12
- /// collected during traversal of `Coverage` statements in the function's MIR.
13
- #[ derive( Debug ) ]
14
- pub ( crate ) struct FunctionCoverageCollector < ' tcx > {
15
- /// Coverage info that was attached to this function by the instrumentor.
16
- function_coverage_info : & ' tcx FunctionCoverageInfo ,
9
+ pub ( crate ) struct FunctionCoverage < ' tcx > {
10
+ pub ( crate ) function_coverage_info : & ' tcx FunctionCoverageInfo ,
17
11
ids_info : & ' tcx CoverageIdsInfo ,
18
12
is_used : bool ,
19
13
}
20
14
21
- impl < ' tcx > FunctionCoverageCollector < ' tcx > {
22
- /// Creates a new set of coverage data for a used (called) function.
23
- pub ( crate ) fn new (
24
- instance : Instance < ' tcx > ,
25
- function_coverage_info : & ' tcx FunctionCoverageInfo ,
26
- ids_info : & ' tcx CoverageIdsInfo ,
27
- ) -> Self {
28
- Self :: create ( instance, function_coverage_info, ids_info, true )
29
- }
30
-
31
- /// Creates a new set of coverage data for an unused (never called) function.
32
- pub ( crate ) fn unused (
33
- instance : Instance < ' tcx > ,
15
+ impl < ' tcx > FunctionCoverage < ' tcx > {
16
+ pub ( crate ) fn new_used (
34
17
function_coverage_info : & ' tcx FunctionCoverageInfo ,
35
18
ids_info : & ' tcx CoverageIdsInfo ,
36
19
) -> Self {
37
- Self :: create ( instance , function_coverage_info, ids_info, false )
20
+ Self { function_coverage_info, ids_info, is_used : true }
38
21
}
39
22
40
- fn create (
41
- instance : Instance < ' tcx > ,
23
+ pub ( crate ) fn new_unused (
42
24
function_coverage_info : & ' tcx FunctionCoverageInfo ,
43
25
ids_info : & ' tcx CoverageIdsInfo ,
44
- is_used : bool ,
45
26
) -> Self {
46
- let num_counters = function_coverage_info. num_counters ;
47
- let num_expressions = function_coverage_info. expressions . len ( ) ;
48
- debug ! (
49
- "FunctionCoverage::create(instance={instance:?}) has \
50
- num_counters={num_counters}, num_expressions={num_expressions}, is_used={is_used}"
51
- ) ;
52
-
53
- Self { function_coverage_info, ids_info, is_used }
54
- }
55
-
56
- pub ( crate ) fn into_finished ( self ) -> FunctionCoverage < ' tcx > {
57
- let FunctionCoverageCollector { function_coverage_info, ids_info, is_used, .. } = self ;
58
-
59
- FunctionCoverage { function_coverage_info, ids_info, is_used }
27
+ Self { function_coverage_info, ids_info, is_used : false }
60
28
}
61
- }
62
-
63
- pub ( crate ) struct FunctionCoverage < ' tcx > {
64
- pub ( crate ) function_coverage_info : & ' tcx FunctionCoverageInfo ,
65
- ids_info : & ' tcx CoverageIdsInfo ,
66
- is_used : bool ,
67
- }
68
29
69
- impl < ' tcx > FunctionCoverage < ' tcx > {
70
30
/// Returns true for a used (called) function, and false for an unused function.
71
31
pub ( crate ) fn is_used ( & self ) -> bool {
72
32
self . is_used
0 commit comments