[BUG] `llvm-cov` warning `mismatched data` when double slash comment above `use`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
bug
llvm-cov warning: 1 functions have mismatched data caused by comment line
background
Found llvm-cov warning: N functions have mismatched data.
After debug, very suprisingly find out this may all caused by comment line.
actual
llvm-cov warning: 1 functions have mismatched data caused by comment line // foo
crate A
#![feature(str_from_raw_parts)]
// foo
use core::str::from_raw_parts;
/// # Safety
///
/// TODO
#[inline]
#[must_use]
pub const unsafe fn str_from_raw_parts<'a>(ptr: *const u8, len: usize) -> &'a str {
from_raw_parts(ptr, len)
}
crate B
use feature_str_from_raw_parts_util::str_from_raw_parts;
#[test]
fn should_ok() {
let x = unsafe { str_from_raw_parts("foobar".as_ptr(), 3) };
let _ = x;
$ yarn cleanup:everything && yarn test:coverage
...
+ /path/to/llvm-cov report ...
warning: 1 functions have mismatched data
...
expected
comment line // foo should not lead to llvm-cov warning: 1 functions have mismatched data
crate A remove comment line
#![feature(str_from_raw_parts)]
use core::str::from_raw_parts;
/// # Safety
///
/// TODO
#[inline]
#[must_use]
pub const unsafe fn str_from_raw_parts<'a>(ptr: *const u8, len: usize) -> &'a str {
from_raw_parts(ptr, len)
}
$ yarn cleanup:everything && yarn test:coverage
...
(llvm-cov no warning)
...
version
rustc 1.82.0-nightly (1f12b9b0f 2024-08-27)
binary: rustc
commit-hash: 1f12b9b0fdbe735968ac002792a720f0ba4faca6
commit-date: 2024-08-27
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 19.1.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report using the two Rust crates shown in the issue and the yarn cleanup:everything && yarn test:coverage command. Compare coverage output with and without the // foo line above the use statement, then trace the relevant Rust coverage and LLVM integration from the failing behavior. Done means the comment no longer produces the mismatched data warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100