Skip to content

Commit dd334dd

Browse files
committed
Adjust future-incompat cfg keyword with raw-idents in cfgs
1 parent 62879c2 commit dd334dd

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

crates/cargo-platform/src/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,13 @@ impl Platform {
117117
}
118118
CfgExpr::Value(ref e) => match e {
119119
Cfg::Name(name) | Cfg::KeyPair(name, _) => {
120-
if KEYWORDS.contains(&name.as_str()) {
120+
if !name.raw && KEYWORDS.contains(&name.as_str()) {
121121
warnings.push(format!(
122122
"[{}] future-incompatibility: `cfg({e})` is deprecated as `{name}` is a keyword \
123123
and not an identifier and should not have have been accepted in this position.\n \
124-
| this was previously accepted by Cargo but is being phased out; it will become a hard error in a future release!",
124+
| this was previously accepted by Cargo but is being phased out; it will become a hard error in a future release!\n \
125+
|\n \
126+
| help: use raw-idents instead: `cfg(r#{name})`",
125127
path.display()
126128
));
127129
}

tests/testsuite/cfg.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,6 @@ fn cfg_raw_idents() {
544544

545545
p.cargo("check")
546546
.with_stderr_data(str![[r#"
547-
[WARNING] [[ROOT]/foo/Cargo.toml] future-incompatibility: `cfg(r#fn)` is deprecated as `r#fn` is a keyword and not an identifier and should not have have been accepted in this position.
548-
| this was previously accepted by Cargo but is being phased out; it will become a hard error in a future release!
549547
[LOCKING] 1 package to latest compatible version
550548
[CHECKING] foo v0.1.0 ([ROOT]/foo)
551549
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
@@ -642,8 +640,12 @@ fn cfg_keywords() {
642640
.with_stderr_data(str![[r#"
643641
[WARNING] [[ROOT]/foo/Cargo.toml] future-incompatibility: `cfg(true)` is deprecated as `true` is a keyword and not an identifier and should not have have been accepted in this position.
644642
| this was previously accepted by Cargo but is being phased out; it will become a hard error in a future release!
643+
|
644+
| [HELP] use raw-idents instead: `cfg(r#true)`
645645
[WARNING] [.cargo/config.toml] future-incompatibility: `cfg(false)` is deprecated as `false` is a keyword and not an identifier and should not have have been accepted in this position.
646646
| this was previously accepted by Cargo but is being phased out; it will become a hard error in a future release!
647+
|
648+
| [HELP] use raw-idents instead: `cfg(r#false)`
647649
[LOCKING] 1 package to latest compatible version
648650
[CHECKING] foo v0.1.0 ([ROOT]/foo)
649651
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s

0 commit comments

Comments
 (0)