Skip to content

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

Open
@est31

Description

@est31

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

Take this code:

#![feature(cfg_version)]

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

With this 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 rust-lang/rust#64796 #[cfg(version(...))] tracking issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions