Suggest correct version("..") predicate syntax in check-cfg

This commit is contained in:
Urgau 2025-05-23 18:14:49 +02:00
parent d423c815a6
commit 343fecabc7
6 changed files with 64 additions and 0 deletions

View file

@ -0,0 +1,14 @@
// Check warning for wrong `cfg(version("1.27"))` syntax
//
//@ check-pass
//@ no-auto-check-cfg
//@ compile-flags: --check-cfg=cfg()
//@ run-rustfix
#![feature(cfg_version)]
#[cfg(not(version("1.48.0")))]
//~^ WARNING unexpected `cfg` condition name: `version`
pub fn g() {}
pub fn main() {}

View file

@ -0,0 +1,14 @@
// Check warning for wrong `cfg(version("1.27"))` syntax
//
//@ check-pass
//@ no-auto-check-cfg
//@ compile-flags: --check-cfg=cfg()
//@ run-rustfix
#![feature(cfg_version)]
#[cfg(not(version = "1.48.0"))]
//~^ WARNING unexpected `cfg` condition name: `version`
pub fn g() {}
pub fn main() {}

View file

@ -0,0 +1,17 @@
warning: unexpected `cfg` condition name: `version`
--> $DIR/wrong-version-syntax.rs:10:11
|
LL | #[cfg(not(version = "1.48.0"))]
| ^^^^^^^^^^^^^^^^^^
|
= help: to expect this configuration use `--check-cfg=cfg(version, values("1.48.0"))`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
= note: `#[warn(unexpected_cfgs)]` on by default
help: there is a similar config predicate: `version("..")`
|
LL - #[cfg(not(version = "1.48.0"))]
LL + #[cfg(not(version("1.48.0")))]
|
warning: 1 warning emitted