[BUG] llvm-cov
warning mismatched data
when double slash comment above use
#130065
Open
Description
opened on Sep 7, 2024
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
Metadata
Assignees
Labels
Area: Source-based code coverage (-Cinstrument-coverage)Area: Code generationCategory: This is a bug.Status: A Minimal Complete and Verifiable Example has been found for this issueRelevant to the compiler team, which will review and decide on the PR/issue.This issue requires a nightly compiler in some way.
Activity