In a`loop` with conditional `return` or `break` within a generic function, the `loop` line doesn't get covered.
**Before raising the issue**
Using `--engine llvm` on macOS. Tarpaulin version 0.35.2, Rust 1.95.0.
**Describe the bug**
When having a combination of `loop`, generic function, and a return/break inside a conditional such as `if`, the `loop` line doesn't get covered.
**To Reproduce**
~~https://github.com/golddranks/tarpaulin_test/blob/main/src/lib.rs~~ Edit: Moved: https://github.com/golddranks/tarpaulin_test/blob/main/loop_problem/src/lib.rs Here's a minimal repro.
```
> cargo tarpaulin
2026-04-18T08:44:49.270592Z INFO cargo_tarpaulin::config: Creating config
2026-04-18T08:44:49.294640Z INFO cargo_tarpaulin: Running Tarpaulin
2026-04-18T08:44:49.294649Z INFO cargo_tarpaulin: Building project
2026-04-18T08:44:49.294698Z INFO cargo_tarpaulin::cargo: Cleaning project
Compiling tarpaulin_test v0.1.0 (/Users/kon/repos/tarpaulin_test)
Finished `test` profile [unoptimized + debuginfo] target(s) in 0.08s
2026-04-18T08:44:49.409591Z INFO cargo_tarpaulin::process_handling: running /Users/kon/repos/tarpaulin_test/target/debug/deps/tarpaulin_test-65d7bec3a6d45a7e
2026-04-18T08:44:49.409623Z INFO cargo_tarpaulin::process_handling: Setting LLVM_PROFILE_FILE
running 1 test
test test_loopers ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
2026-04-18T08:44:49.657151Z INFO cargo_tarpaulin::statemachine::instrumented: For binary: target/debug/deps/tarpaulin_test-65d7bec3a6d45a7e
2026-04-18T08:44:49.657164Z INFO cargo_tarpaulin::statemachine::instrumented: Generated: target/tarpaulin/profraws/tarpaulin_test-65d7bec3a6d45a7e_6873750808621456252_0-96330.profraw
2026-04-18T08:44:49.657169Z INFO cargo_tarpaulin::statemachine::instrumented: Merging coverage reports
2026-04-18T08:44:49.657288Z INFO cargo_tarpaulin::statemachine::instrumented: Mapping coverage data to source
2026-04-18T08:44:49.657640Z INFO cargo_tarpaulin::report: Coverage Results:
|| Uncovered Lines:
|| src/lib.rs: 3, 18
|| Tested/Total Lines:
|| src/lib.rs: 18/20 +0.00%
||
90.00% coverage, 18/20 lines covered, +0.00% change in coverage
```
Two `loop` lines don't get covered (indicated as comments in the code).
**Expected behavior**
I'd expect 100% coverage.
关闭于 2026-04-25 1 条评论