Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Zinstrument-coverage and matches!() #84892

Open
scole66 opened this issue May 4, 2021 · 6 comments
Open

-Zinstrument-coverage and matches!() #84892

scole66 opened this issue May 4, 2021 · 6 comments
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@scole66
Copy link

scole66 commented May 4, 2021

When using -Zinstrument-coverage on a recent (first-week-of-May-2021) nightly, the matches! macro is no longer marked covered. (This is likely related to macro coverage rules recently adjusted.) The macro was marked covered earlier in April.

  | res::scanner::tests::template_test_09:
  | 2957|      1|    fn template_test_09() {
  | 2958|      1|        let r = scan_token(&Scanner::new(), "`\\", ScanGoal::InputElementRegExp);
  | 2959|      1|        let (token, scanner) = r;
  | 2960|      1|        assert_eq!(scanner, Scanner { line: 1, column: 1, start_idx: 0 });
  | 2961|      1|        assert!(matches!(token, Token::Error(_)));
  |                              ^0
  | 2962|      1|    }

Meta

rustc --version --verbose:

rustc 1.54.0-nightly (716394d65 2021-05-03)
binary: rustc
commit-hash: 716394d6581b60c75cfdd88b8e5b876f2db88b62
commit-date: 2021-05-03
host: x86_64-unknown-linux-gnu
release: 1.54.0-nightly
LLVM version: 12.0.0
@scole66 scole66 added the C-bug Category: This is a bug. label May 4, 2021
@jackh726 jackh726 added the A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) label May 4, 2021
@scole66
Copy link
Author

scole66 commented May 4, 2021

/cc @richkadel

@Enselic Enselic added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Dec 17, 2023
@Enselic
Copy link
Member

Enselic commented Dec 17, 2023

Triage: Can you still reproduce this? If yes, can you add a minimal reproducer please?

@scole66
Copy link
Author

scole66 commented Dec 18, 2023

yes, I can still repro this. I don't have a minimized reproducer though; that'll take a half an hour maybe tomorrow...

@kpreid
Copy link
Contributor

kpreid commented Dec 25, 2023

Triage: Relabeling issues which don't have a runnable reproduction (as opposed to having a non-minimized one) to the new label S-needs-repro.
@rustbot label +S-needs-repro -E-needs-mcve

@rustbot rustbot added S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. and removed E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Dec 25, 2023
@scole66
Copy link
Author

scole66 commented Dec 26, 2023

Minimal Reproducer:

main.rs:

fn main() {
    assert!(matches!(Some(10), Some(_)));
}

#[cfg(test)]
#[test]
fn run() {
    main()
}

Test runner bash script:

output=cov-testcase.profdata;
function tst ()
{
    rm -f cov-testcase-*.profraw
    RUST_BACKTRACE=1 LLVM_PROFILE_FILE="cov-testcase-%m.profraw" RUSTFLAGS="-Cinstrument-coverage" cargo test
    local covstatus=$?
    if [ $covstatus -eq 0 ]; then
        cargo profdata -- merge cov-testcase-*.profraw --output="$output"
    fi
    return $covstatus
}
function objects() {
    for file in $( \
        LLVM_PROFILE_FILE="cov-testcase-%m.profraw" RUSTFLAGS="-Cinstrument-coverage" cargo test --no-run --message-format=json 2> /dev/null | \
            jq -r "select(.profile.test == true) | .filenames[]" | \
            grep -v dSYM - \
        ); do
        /bin/echo -n "-object $file ";
    done
    echo
}
tst
cargo cov -- show \
    --instr-profile="$output" \
    $(objects) \
    --show-line-counts-or-regions \
    --name main \
    -Xdemangler=rustfilt

Output:

$ ./doit.sh 
    Finished test [unoptimized + debuginfo] target(s) in 0.00s
     Running unittests src/main.rs (target/debug/deps/cov_testcase-c24dc8f1fbb12e98)

running 1 test
test run ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

cov_testcase::main:
    1|      1|fn main() {
    2|      1|    assert!(matches!(Some(10), Some(_)));
                          ^0
    3|      1|}

@scole66
Copy link
Author

scole66 commented Dec 31, 2023

@rustbot label -S-needs-repro

@rustbot rustbot removed the S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. label Dec 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants