@@ -385,8 +385,7 @@ fn add_unused_functions(cx: &CodegenCx<'_, '_>) {
385
385
} ;
386
386
387
387
debug ! ( "generating unused fn: {def_id:?}" ) ;
388
- let instance = declare_unused_fn ( tcx, def_id) ;
389
- add_unused_function_coverage ( cx, instance, function_coverage_info) ;
388
+ add_unused_function_coverage ( cx, def_id, function_coverage_info) ;
390
389
}
391
390
}
392
391
@@ -421,8 +420,15 @@ fn codegenned_and_inlined_items(tcx: TyCtxt<'_>) -> DefIdSet {
421
420
result
422
421
}
423
422
424
- fn declare_unused_fn < ' tcx > ( tcx : TyCtxt < ' tcx > , def_id : DefId ) -> ty:: Instance < ' tcx > {
425
- ty:: Instance :: new (
423
+ fn add_unused_function_coverage < ' tcx > (
424
+ cx : & CodegenCx < ' _ , ' tcx > ,
425
+ def_id : DefId ,
426
+ function_coverage_info : & ' tcx mir:: coverage:: FunctionCoverageInfo ,
427
+ ) {
428
+ let tcx = cx. tcx ;
429
+
430
+ // Make a dummy instance that fills in all generics with placeholders.
431
+ let instance = ty:: Instance :: new (
426
432
def_id,
427
433
ty:: GenericArgs :: for_item ( tcx, def_id, |param, _| {
428
434
if let ty:: GenericParamDefKind :: Lifetime = param. kind {
@@ -431,14 +437,8 @@ fn declare_unused_fn<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> ty::Instance<'tc
431
437
tcx. mk_param_from_def ( param)
432
438
}
433
439
} ) ,
434
- )
435
- }
440
+ ) ;
436
441
437
- fn add_unused_function_coverage < ' tcx > (
438
- cx : & CodegenCx < ' _ , ' tcx > ,
439
- instance : ty:: Instance < ' tcx > ,
440
- function_coverage_info : & ' tcx mir:: coverage:: FunctionCoverageInfo ,
441
- ) {
442
442
// An unused function's mappings will automatically be rewritten to map to
443
443
// zero, because none of its counters/expressions are marked as seen.
444
444
let function_coverage = FunctionCoverageCollector :: unused ( instance, function_coverage_info) ;
0 commit comments