Skip to content

Make comptime functions ineligible for coverage - #162354

Open
Zalathar wants to merge 1 commit into
rust-lang:mainfrom
Zalathar:comptime
Open

Make comptime functions ineligible for coverage#162354
Zalathar wants to merge 1 commit into
rust-lang:mainfrom
Zalathar:comptime

Conversation

@Zalathar

@Zalathar Zalathar commented Sep 6, 2026

Copy link
Copy Markdown
Member

As reported in #161808, the assertion in #159777 causes the compiler to ICE when it tries to generate an unused-function record for comptime functions, because comptime functions aren't allowed to have a symbol name. This can occur when trying to instrument core, for example.

Compile-time-only functions don't generate code, so instrumenting them for coverage is useless anyway. This PR therefore makes them ineligible for coverage, which avoids the problem.


This PR is essentially a rewrite of #161808. I wanted to request several modifications to that PR, and the overall change is small enough that it was easier for me to just recreate it from scratch.

The main differences are:

  • Adds a coverage test instead of a ui test
  • Comments focus more on the fact that instrumenting comptime functions isn't useful, with avoiding the ICE being a secondary motivation

cc @fmease @oli-obk as I'm not familiar with comptime

@Zalathar Zalathar added the A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) label Sep 6, 2026
@rustbot

rustbot commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 6, 2026
@rustbot

rustbot commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

r? @mati865

rustbot has assigned @mati865.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 19 candidates

Compile-time-only functions don't generate code, so instrumenting them for
coverage is useless.

This also avoids an ICE when trying to get the function's symbol name for an
unused-function record, which can occur when instrumenting `core`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants