Skip to content

Commit aa8bb59

Browse files
committed
Adjust future-incompat cfg keyword with raw-idents in cfgs
1 parent d150663 commit aa8bb59

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-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

+16-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,20 +640,36 @@ fn cfg_keywords() {
642640
.with_stderr_data(str![[r#"
643641
[WARNING] [[ROOT]/foo/Cargo.toml] future-incompatibility: `cfg(async)` is deprecated as `async` 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#async)`
645645
[WARNING] [[ROOT]/foo/Cargo.toml] future-incompatibility: `cfg(fn)` is deprecated as `fn` 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#fn)`
647649
[WARNING] [[ROOT]/foo/Cargo.toml] future-incompatibility: `cfg(const)` is deprecated as `const` is a keyword and not an identifier and should not have have been accepted in this position.
648650
| this was previously accepted by Cargo but is being phased out; it will become a hard error in a future release!
651+
|
652+
| [HELP] use raw-idents instead: `cfg(r#const)`
649653
[WARNING] [[ROOT]/foo/Cargo.toml] future-incompatibility: `cfg(return)` is deprecated as `return` is a keyword and not an identifier and should not have have been accepted in this position.
650654
| this was previously accepted by Cargo but is being phased out; it will become a hard error in a future release!
655+
|
656+
| [HELP] use raw-idents instead: `cfg(r#return)`
651657
[WARNING] [.cargo/config.toml] future-incompatibility: `cfg(for)` is deprecated as `for` is a keyword and not an identifier and should not have have been accepted in this position.
652658
| this was previously accepted by Cargo but is being phased out; it will become a hard error in a future release!
659+
|
660+
| [HELP] use raw-idents instead: `cfg(r#for)`
653661
[WARNING] [.cargo/config.toml] future-incompatibility: `cfg(match)` is deprecated as `match` is a keyword and not an identifier and should not have have been accepted in this position.
654662
| this was previously accepted by Cargo but is being phased out; it will become a hard error in a future release!
663+
|
664+
| [HELP] use raw-idents instead: `cfg(r#match)`
655665
[WARNING] [.cargo/config.toml] future-incompatibility: `cfg(extern)` is deprecated as `extern` is a keyword and not an identifier and should not have have been accepted in this position.
656666
| this was previously accepted by Cargo but is being phased out; it will become a hard error in a future release!
667+
|
668+
| [HELP] use raw-idents instead: `cfg(r#extern)`
657669
[WARNING] [.cargo/config.toml] future-incompatibility: `cfg(crate)` is deprecated as `crate` is a keyword and not an identifier and should not have have been accepted in this position.
658670
| this was previously accepted by Cargo but is being phased out; it will become a hard error in a future release!
671+
|
672+
| [HELP] use raw-idents instead: `cfg(r#crate)`
659673
[LOCKING] 1 package to latest compatible version
660674
[CHECKING] foo v0.1.0 ([ROOT]/foo)
661675
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s

0 commit comments

Comments
 (0)