rust-lang / rust-lang/rust-clippy
incompatible_msrv doesn't respect #[cfg(version(...))]
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
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 https://github.com/rust-lang/rust/issues/64796 #[cfg(version(...))] tracking issue
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the provided Rust example with the incompatible_msrv lint and inspect the lint's handling of items gated by #[cfg(version(...))]. Add coverage for the shown std::io::pipe() case and verify that the lint no longer reports code excluded by the configured MSRV; existing behavior for ungated code should remain intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100