@@ -3,70 +3,30 @@ use rustc_middle::mir::coverage::{
33 CovTerm , CoverageIdsInfo , Expression , FunctionCoverageInfo , Mapping , MappingKind , Op ,
44 SourceRegion ,
55} ;
6- use rustc_middle:: ty:: Instance ;
7- use tracing:: debug;
86
97use crate :: coverageinfo:: ffi:: { Counter , CounterExpression , ExprKind } ;
108
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 ,
1711 ids_info : & ' tcx CoverageIdsInfo ,
1812 is_used : bool ,
1913}
2014
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 (
3417 function_coverage_info : & ' tcx FunctionCoverageInfo ,
3518 ids_info : & ' tcx CoverageIdsInfo ,
3619 ) -> Self {
37- Self :: create ( instance , function_coverage_info, ids_info, false )
20+ Self { function_coverage_info, ids_info, is_used : true }
3821 }
3922
40- fn create (
41- instance : Instance < ' tcx > ,
23+ pub ( crate ) fn new_unused (
4224 function_coverage_info : & ' tcx FunctionCoverageInfo ,
4325 ids_info : & ' tcx CoverageIdsInfo ,
44- is_used : bool ,
4526 ) -> 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 }
6028 }
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- }
6829
69- impl < ' tcx > FunctionCoverage < ' tcx > {
7030 /// Returns true for a used (called) function, and false for an unused function.
7131 pub ( crate ) fn is_used ( & self ) -> bool {
7232 self . is_used
0 commit comments