Closed
Description
Summary
I believe the warn-by-default incompatible_msrv
lint should not apply to tests.
The "Why is this bad?" description of the lint says:
It would prevent the crate to be actually used with the specified MSRV.
However, test-only code does not prevent the crate from being used with the specified MSRV, as a library. Tests are not compiled when a crate is used as a dependency.
#![cfg_attr(test, allow(clippy::incompatible_msrv))]
is possible as a workaround but I believe this should not be necessary: the default behavior of the warn-by-default lint should be that tests are not considered. If MSRV enforcement for tests is valuable to some users, that should be a separate restriction
lint.
Lint Name
incompatible_msrv
Reproducer
# Cargo.toml
[package]
name = "repro"
edition = "2018"
rust-version = "1.31"
// src/lib.rs
#[test]
fn repro() {
assert_ne!(f32::NAN.copysign(1.0), f32::NAN);
}
$ cargo clippy --tests
warning: current MSRV (Minimum Supported Rust Version) is `1.31.0` but this item is stable since `1.35.0`
--> src/lib.rs:5:25
|
5 | assert_ne!(f32::NAN.copysign(1.0), f32::NAN);
| ^^^^^^^^^^^^^
|
= 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
Version
rustc 1.78.0-nightly (d44e3b95c 2024-02-09)
binary: rustc
commit-hash: d44e3b95cb9d410d89cb8ab3233906a33f43756a
commit-date: 2024-02-09
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 17.0.6
Additional Labels
No response