Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
est31 opened this issue May 17, 2025 · 1 comment
Open

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

est31 opened this issue May 17, 2025 · 1 comment

Comments

@est31
Copy link
Member

est31 commented May 17, 2025

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

@Alexendoo
Copy link
Member

Was planning to quickly take care of that but any()/all() complicate it a bit. Just parsing the plain cfg(version) is an option

Up for grabs for now, may take another look at it next week if nobody else does in the meanwhile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants