#14827·rust-clippy

incompatible_msrv doesn't respect #[cfg(version(...))]

Author: est31Created May 17, 2025Updated Sep 17, 2026
LabelsG-Rust-for-Linux

The incompatible_msrv lint doesn't recognize that code is gated by #[cfg(version(...))], and complains about the usage anyways.

Take this code:

rust
#![feature(cfg_version)]

pub fn maybe_pipe() {
    #[cfg(version("1.87"))]
    let _ = std::io::pipe(); // stabilized in 1.87.0
}

With this toml:

toml
[package]
name = "cfg-version-test"
version = "0.1.0"
edition = "2024"
rust-version = "1.85.0"

[dependencies]

It will lint, even though the code is fine:

warning: current MSRV (Minimum Supported Rust Version) is `1.85.0` but this item is stable since `1.87.0`
 --> src/lib.rs:5:13
  |
5 |     let _ = std::io::pipe();
  |             ^^^^^^^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv
  = note: `#[warn(clippy::incompatible_msrv)]` on by default

cc https://github.com/rust-lang/rust/issues/64796 #[cfg(version(...))] tracking issue