Skip to content

incompatible_msrv reported even when method is not called #15792

@ijackson

Description

@ijackson

Summary

In our code we take the fn value std::any::TypeId::of::<something> in a const context. We later call that function value in a non-const context. This triggers this warning even though our code does not have an MSRV violation.

Lint Name

incompatible_msrv

Reproducer

I tried this code (note that ::of isn't called: we have of::<()> not of::<()>():

// in `Cargo.toml`
// rust-version = "1.85.1"

const _ : () = {
    let _ = std::any::TypeId::of::<()>;
};

I saw this happen:

warning: current MSRV (Minimum Supported Rust Version) is `1.85.1` but this item is stable in a `const` context since `1.91.0`
 --> src/lib.rs:3:13
  |
3 |     let _ = std::any::TypeId::of::<()>;
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/beta/index.html#incompatible_msrv
  = note: `#[warn(clippy::incompatible_msrv)]` on by default

I expected to see this happen:

clippy is happy.

Version

rustc 1.91.0-beta.4 (aa7859c0d 2025-09-27)
binary: rustc
commit-hash: aa7859c0dec2de6c9cab34b03028bcef7b1fc25d
commit-date: 2025-09-27
host: x86_64-unknown-linux-gnu
release: 1.91.0-beta.4
LLVM version: 21.1.1

Additional Labels

@rustbot label +regression-from-stable-to-beta

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveP-mediumPriority: Medium

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions