Skip to content

Commit 363c9b7

Browse files
committed
Adjust future-incompatibility cfg keyword with raw-idents in cfgs
1 parent c1915bc commit 363c9b7

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

crates/cargo-platform/src/lib.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,25 @@ 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
if name.as_str() == "true" || name.as_str() == "false" {
122122
warnings.push(format!(
123123
"[{}] future-incompatibility: the meaning of `cfg({e})` will change in the future\n \
124124
| Cargo is erroneously allowing `cfg(true)` and `cfg(false)`, but both forms are interpreted as false unless manually overridden with `--cfg`.\n \
125125
| In the future these will be built-in defines that will have the corresponding true/false value.\n \
126126
| It is recommended to avoid using these configs until they are properly supported.\n \
127-
| See <https://github.com/rust-lang/rust/issues/131204> for more information.",
127+
| See <https://github.com/rust-lang/rust/issues/131204> for more information.\n \
128+
|\n \
129+
| help: use raw-idents instead: `cfg(r#{name})`",
128130
path.display()
129131
));
130132
} else {
131133
warnings.push(format!(
132134
"[{}] future-incompatibility: `cfg({e})` is deprecated as `{name}` is a keyword \
133135
and not an identifier and should not have have been accepted in this position.\n \
134-
| this was previously accepted by Cargo but is being phased out; it will become a hard error in a future release!",
136+
| this was previously accepted by Cargo but is being phased out; it will become a hard error in a future release!\n \
137+
|\n \
138+
| help: use raw-idents instead: `cfg(r#{name})`",
135139
path.display()
136140
));
137141
}

tests/testsuite/cfg.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -544,11 +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: the meaning of `cfg(r#true)` will change in the future
548-
| Cargo is erroneously allowing `cfg(true)` and `cfg(false)`, but both forms are interpreted as false unless manually overridden with `--cfg`.
549-
| In the future these will be built-in defines that will have the corresponding true/false value.
550-
| It is recommended to avoid using these configs until they are properly supported.
551-
| See <https://github.com/rust-lang/rust/issues/131204> for more information.
552547
[LOCKING] 1 package to latest compatible version
553548
[CHECKING] foo v0.1.0 ([ROOT]/foo)
554549
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
@@ -648,11 +643,15 @@ fn cfg_keywords() {
648643
| In the future these will be built-in defines that will have the corresponding true/false value.
649644
| It is recommended to avoid using these configs until they are properly supported.
650645
| See <https://github.com/rust-lang/rust/issues/131204> for more information.
646+
|
647+
| [HELP] use raw-idents instead: `cfg(r#true)`
651648
[WARNING] [.cargo/config.toml] future-incompatibility: the meaning of `cfg(false)` will change in the future
652649
| Cargo is erroneously allowing `cfg(true)` and `cfg(false)`, but both forms are interpreted as false unless manually overridden with `--cfg`.
653650
| In the future these will be built-in defines that will have the corresponding true/false value.
654651
| It is recommended to avoid using these configs until they are properly supported.
655652
| See <https://github.com/rust-lang/rust/issues/131204> for more information.
653+
|
654+
| [HELP] use raw-idents instead: `cfg(r#false)`
656655
[LOCKING] 1 package to latest compatible version
657656
[CHECKING] foo v0.1.0 ([ROOT]/foo)
658657
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s

0 commit comments

Comments
 (0)