Skip to content

fix(multitude): restore coverage for transcode_utf16_into#499

Open
martin-kolinek wants to merge 1 commit into
mainfrom
fix/multitude-utf16-coverage-inline
Open

fix(multitude): restore coverage for transcode_utf16_into#499
martin-kolinek wants to merge 1 commit into
mainfrom
fix/multitude-utf16-coverage-inline

Conversation

@martin-kolinek

Copy link
Copy Markdown
Collaborator

Problem

PR #478 (feat(thread_aware): add feature-gated ThreadAware impls for 3rd-party crate types) dropped codecov coverage on main from 100% to 99.9% even though it didn't touch the multitude crate at all (its own patch coverage was 100%).

The 11 missed lines are all the body of the private transcode_utf16_into helper in crates/multitude/src/arena/alloc_utf16.rs: lines 213, 219–225, 227, 228, 230.

Root cause

The helper is #[inline(always)], so no out-of-line function body exists in the compiled test binary. cargo llvm-cov has to attribute hits to the inlined copies via debuginfo, and that mapping is fragile — it shifted when PR #478 added new optional deps (bytes, http, jiff02, uuid) to thread_aware, which is a transitive dep of multitude via bytesbuf. The function is still exercised by existing tests (alloc_utf16_str_arc_from_str, the oversized routes tests added in #487, etc.); coverage just stops getting attributed to the source lines.

Fix

Gate the inline(always) on not(coverage_nightly):

#[cfg_attr(not(coverage_nightly), inline(always))]

Under coverage instrumentation the function keeps a real callable body that llvm-cov attributes hits to deterministically. Release/dev/CI test builds keep inline(always) exactly as today — zero perf change for users.

The coverage_nightly cfg is already a known idiom in this crate (used widely with #[coverage(off)] and feature(coverage_attribute)).

Verification

Ran cargo +nightly-2026-05-30 llvm-cov --all-features -p multitude --lcov locally:

  • Before: alloc_utf16.rs reports 72 hit / 11 missed (exactly lines 213, 219–225, 227, 228, 230 — matches what codecov shows on main).
  • After: alloc_utf16.rs reports 83 hit / 0 missed. 100% restored.

PR #478 (feat(thread_aware): add feature-gated ThreadAware impls for 3rd-party crate types) dropped codecov from 100% to 99.9% even though it didn't touch multitude. The 11 missed lines are the body of the private `transcode_utf16_into` helper in `crates/multitude/src/arena/alloc_utf16.rs`.

Root cause: the helper is `#[inline(always)]`, so no out-of-line copy exists in the test binary. llvm-cov has to attribute hits to inlined copies via debuginfo, and that mapping is fragile -- it shifted when PR #478 added new optional deps (`bytes`, `http`, `jiff02`, `uuid`) to `thread_aware`, which is a transitive dep of multitude via bytesbuf.

Fix: gate the `inline(always)` on `not(coverage_nightly)` so under coverage instrumentation the function keeps a real callable body that llvm-cov attributes hits to deterministically. Release/dev/CI test builds keep `inline(always)` exactly as today -- zero perf change for users.

Verified locally with `cargo +nightly-2026-05-30 llvm-cov --all-features -p multitude --lcov`: before the change, alloc_utf16.rs reports 72 hit / 11 missed (exactly lines 213, 219-225, 227, 228, 230); after the change, 83 hit / 0 missed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 12, 2026 17:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores deterministic llvm-cov line attribution for multitude’s private UTF-16 transcoding helper by avoiding forced inlining during coverage builds, addressing a recent project coverage drop without changing runtime behavior for normal builds.

Changes:

  • Replaces unconditional #[inline(always)] on transcode_utf16_into with #[cfg_attr(not(coverage_nightly), inline(always))].
  • Adds an inline comment explaining why coverage builds should keep an out-of-line function body for stable line mapping.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.0%. Comparing base (fc13464) to head (05f5f2e).

Additional details and impacted files
@@          Coverage Diff           @@
##            main     #499   +/-   ##
======================================
  Coverage   99.9%   100.0%           
======================================
  Files        336      336           
  Lines      24829    24829           
======================================
+ Hits       24818    24829   +11     
+ Misses        11        0   -11     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants