From 7be6624d5920005c45aed95aeb67e67f519cbbfe Mon Sep 17 00:00:00 2001 From: "Martin Kolinek (from Dev Box)" Date: Tue, 22 Sep 2026 17:46:11 +0200 Subject: [PATCH] fix(cargo-coverage-gate): eliminate unkillable format_delta mutant format_delta rounded a non-zero delta and then branched on rounded > 0.0 / rounded < 0.0 / else. Once the sub-precision guard above rules out |delta| < ~0.1, the rounded tenth can never land back on exactly 0.0, so the rounded < 0.0 branch was unreachable and mutating it to rounded <= 0.0 produced an equivalent mutant that no test could kill. cargo-mutants flagged this as MISSED on both the Linux and Windows legs of the scheduled-exhaustive workflow, failing anvil-mutants-full with exit code 2. Restructure the branch to check rounded == 0.0 first, then dispatch on rounded.is_sign_positive() for the sign. This keeps every observable case covered by the existing unit tests while removing the redundant comparison that could never be exercised. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- crates/cargo-coverage-gate/src/render/mod.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/crates/cargo-coverage-gate/src/render/mod.rs b/crates/cargo-coverage-gate/src/render/mod.rs index 1fe60ab57..a97f1cbad 100644 --- a/crates/cargo-coverage-gate/src/render/mod.rs +++ b/crates/cargo-coverage-gate/src/render/mod.rs @@ -82,14 +82,21 @@ fn format_delta(outcome: &PackageOutcome) -> String { return "-<0.1pp".to_owned(); } - // Ordinary values use the displayed precision of one decimal place. + // Ordinary values use the displayed precision of one decimal place. Once + // `delta` clears the sub-precision guard above, its rounded tenth can + // never land back on zero (rounding a value whose magnitude is already + // >= `DELTA_DISPLAY_PRECISION - DELTA_BOUNDARY_TOLERANCE` cannot produce + // `0.0`), so a `rounded < 0.0` branch here is unreachable and would be an + // equivalent mutant against `rounded <= 0.0`. Checking `is_sign_positive` + // after handling zero explicitly avoids that redundant comparison. let rounded = (delta * 10.0).round() / 10.0; - if rounded > 0.0 { + if rounded == 0.0 { + return "0.0pp".to_owned(); + } + if rounded.is_sign_positive() { format!("+{rounded:.1}pp") - } else if rounded < 0.0 { - format!("{rounded:.1}pp") } else { - "0.0pp".to_owned() + format!("{rounded:.1}pp") } }