Skip to content

LLVM Coverage and "assert_eq!" #82853

Closed
Closed
@scole66

Description

@scole66

When using -Zinstrument-coverage, my coverage reports often (but not always), report things like:

res::strings::tests::iterator_test_01:
  253|      1|    fn iterator_test_01() {
  254|      1|        let mystr = "blue\u{E00E}";
  255|      1|        let i = CharToU16Iterator::new(mystr);
  256|      1|        let res: Vec<u16> = i.collect();
  257|      0|        assert_eq!(res, &[98, 108, 117, 101, 0xe00e]);
  258|      1|    }

I.e.: the assert_eq! is marked with no coverage. (Now, it's a whole other can of worms for why my testcases themselves should be included in coverage, but I think that's a question for the llvm people, not the rust people.)

Naturally, my expectation is that all the lines of this non-branching testcase have the same execution counts.

I've changed things around, on occasion, to assert!(a == b) instead, and that seems to resolve things, but I'd really rather not have to go to that step.

Meta

rustc --version --verbose:

rustc 1.52.0-nightly (caca2121f 2021-03-05)
binary: rustc
commit-hash: caca2121ffe4cb47d8ea2d9469c493995f57e0b5
commit-date: 2021-03-05
host: x86_64-unknown-linux-gnu
release: 1.52.0-nightly
LLVM version: 12.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-code-coverageArea: Source-based code coverage (-Cinstrument-coverage)C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions