You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Missing coverage on assert!(!...) statements #118904
I expected to see this happen: Run this program with cargo-llvm-cov: cargo llvm-cov run --html, I expect the source code should be fully covered.
Instead, this happened: The assert! part in the source code is not covered. But if I change !false to true, the source will be fully covered, it seems that I can’t get assert! to be covered as long as the argument starts with an ! operator.
@matthiaskrgr: I think cargo-llvm-cov already uses opt-level=0 by default. Nevertheless, I have tested using env RUSTFLAGS='-Copt-level=0' cargo llvm-cov run --html, and the result is the same.
This may be a similar case to #110486. It seems that something odd is happening when the compiler gets the coverage of the code generated by the macro and maps it to the original code.
Activity
[-]Missing coverage on expression `assert!(!...)` statement[/-][+]Missing coverage on `assert!(!...)` statements[/+]matthiaskrgr commentedon Dec 13, 2023
Might be that llvm just optimizes it out as dead code. Do you see it with -Copt-level=0 ?
EFanZh commentedon Dec 13, 2023
@matthiaskrgr: I think
cargo-llvm-covalready usesopt-level=0by default. Nevertheless, I have tested usingenv RUSTFLAGS='-Copt-level=0' cargo llvm-cov run --html, and the result is the same.taiki-e commentedon Dec 13, 2023
This may be a similar case to #110486. It seems that something odd is happening when the compiler gets the coverage of the code generated by the macro and maps it to the original code.
@rustbot label +A-code-coverage
Noratrieb commentedon Dec 15, 2023
cc @Zalathar
Zalathar commentedon Dec 16, 2023
I can reproduce this with
2023-12-08but not with2023-12-14.It was probably fixed by #118198.
Noratrieb commentedon Dec 16, 2023
Would it make sense to add a test for this specifically?
Zalathar commentedon Dec 16, 2023
PR filed: #119011
Rollup merge of rust-lang#119011 - Zalathar:assert-not, r=est31
Auto merge of rust-lang#119011 - Zalathar:assert-not, r=est31
ranger-ross commentedon Aug 31, 2024
A bit late, but I re-tested this on Rust 1.80.0 and it look like #119011 fixed the issue.
I think we are good to close this issue 👍