@@ -357,31 +357,27 @@ fn add_unused_functions(cx: &CodegenCx<'_, '_>) {
357357
358358 let ignore_unused_generics = tcx. sess . instrument_coverage_except_unused_generics ( ) ;
359359
360- let eligible_def_ids: Vec < DefId > = tcx
361- . mir_keys ( ( ) )
362- . iter ( )
363- . filter_map ( |local_def_id| {
364- let def_id = local_def_id. to_def_id ( ) ;
365- let kind = tcx. def_kind ( def_id) ;
366- // `mir_keys` will give us `DefId`s for all kinds of things, not
367- // just "functions", like consts, statics, etc. Filter those out.
368- // If `ignore_unused_generics` was specified, filter out any
369- // generic functions from consideration as well.
370- if !matches ! ( kind, DefKind :: Fn | DefKind :: AssocFn | DefKind :: Closure ) {
371- return None ;
372- }
373- if ignore_unused_generics && tcx. generics_of ( def_id) . requires_monomorphization ( tcx) {
374- return None ;
375- }
376- Some ( local_def_id. to_def_id ( ) )
377- } )
378- . collect ( ) ;
360+ let eligible_def_ids = tcx. mir_keys ( ( ) ) . iter ( ) . filter_map ( |local_def_id| {
361+ let def_id = local_def_id. to_def_id ( ) ;
362+ let kind = tcx. def_kind ( def_id) ;
363+ // `mir_keys` will give us `DefId`s for all kinds of things, not
364+ // just "functions", like consts, statics, etc. Filter those out.
365+ // If `ignore_unused_generics` was specified, filter out any
366+ // generic functions from consideration as well.
367+ if !matches ! ( kind, DefKind :: Fn | DefKind :: AssocFn | DefKind :: Closure ) {
368+ return None ;
369+ }
370+ if ignore_unused_generics && tcx. generics_of ( def_id) . requires_monomorphization ( tcx) {
371+ return None ;
372+ }
373+ Some ( local_def_id. to_def_id ( ) )
374+ } ) ;
379375
380376 let codegenned_def_ids = codegenned_and_inlined_items ( tcx) ;
381377
382378 // For each `DefId` that should have coverage instrumentation but wasn't
383379 // codegenned, add it to the function coverage map as an unused function.
384- for def_id in eligible_def_ids. into_iter ( ) . filter ( |id| !codegenned_def_ids. contains ( id) ) {
380+ for def_id in eligible_def_ids. filter ( |id| !codegenned_def_ids. contains ( id) ) {
385381 // Skip any function that didn't have coverage data added to it by the
386382 // coverage instrumentor.
387383 let body = tcx. instance_mir ( ty:: InstanceDef :: Item ( def_id) ) ;
0 commit comments