Skip to content

Commit

Permalink
coverage: Don't use HIR to determine whether a def is fn-like
Browse files Browse the repository at this point in the history
  • Loading branch information
Zalathar committed Dec 5, 2023
1 parent 0832a21 commit 1bc26f4
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions compiler/rustc_mir_build/src/build/coverageinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ pub(crate) fn make_coverage_hir_info_if_eligible(
}

fn is_eligible_for_coverage(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
let is_fn_like = tcx.hir().get_by_def_id(def_id).fn_kind().is_some();

// Only instrument functions, methods, and closures (not constants since they are evaluated
// at compile time by Miri).
// FIXME(#73156): Handle source code coverage in const eval, but note, if and when const
// expressions get coverage spans, we will probably have to "carve out" space for const
// expressions from coverage spans in enclosing MIR's, like we do for closures. (That might
// be tricky if const expressions have no corresponding statements in the enclosing MIR.
// Closures are carved out by their initial `Assign` statement.)
if !is_fn_like {
if !tcx.def_kind(def_id).is_fn_like() {
return false;
}

Expand Down

0 comments on commit 1bc26f4

Please sign in to comment.