rust-lang / rust-lang/rust

[BUG] `llvm-cov` warning `mismatched data` when impl const fn

Open
#130,139 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-code-coverage A-LLVM C-bug S-has-mcve T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

bug

llvm-cov warning mismatched data when impl const fn

reproduce

https://github.com/loynoir/reproduce-rust-130139

pub use bar::Bar;

mod bar {
    pub struct Bar<T>(T);

    impl Bar<i32> {
        pub const unsafe fn from_unchecked(value: i32) -> Self {
            Bar(value)
        }

        pub const fn get(&self) -> i32 {
            self.0
        }
    }
}

workaround

pub use bar::{Bar, bar_get_i32};

mod bar {
    pub struct Bar<T>(T);

    impl Bar<i32> {
        pub const unsafe fn from_unchecked(value: i32) -> Self {
            Bar(value)
        }

        pub fn get(&self) -> i32 {
            self.0
        }
    }

    pub fn bar_get_i32(bar: &Bar<i32>) -> i32 {
        bar.0
    }
}

related

llvm-cov warning mismatched data when double slash comment above use

https://github.com/rust-lang/rust/issues/130065

llvm-cov warning mismatched data when triple slash safety comment above unsafe fn

https://github.com/rust-lang/rust/issues/130097

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked reproduction repository and run its llvm-cov example to confirm the mismatched data warning. Compare the const and non-const get cases, then read the related issues #130065 and #130097 for coverage of similar warnings. Done means the reported case no longer produces mismatched coverage data and has a regression test.

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
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.