diff --git a/crates/cargo-platform/src/lib.rs b/crates/cargo-platform/src/lib.rs index 421085b61b77..f91b61708bb4 100644 --- a/crates/cargo-platform/src/lib.rs +++ b/crates/cargo-platform/src/lib.rs @@ -117,21 +117,25 @@ impl Platform { } CfgExpr::Value(ref e) => match e { Cfg::Name(name) | Cfg::KeyPair(name, _) => { - if KEYWORDS.contains(&name.as_str()) { + if !name.raw && KEYWORDS.contains(&name.as_str()) { if name.as_str() == "true" || name.as_str() == "false" { warnings.push(format!( "[{}] future-incompatibility: the meaning of `cfg({e})` will change in the future\n \ | Cargo is erroneously allowing `cfg(true)` and `cfg(false)`, but both forms are interpreted as false unless manually overridden with `--cfg`.\n \ | In the future these will be built-in defines that will have the corresponding true/false value.\n \ | It is recommended to avoid using these configs until they are properly supported.\n \ - | See for more information.", + | See for more information.\n \ + |\n \ + | help: use raw-idents instead: `cfg(r#{name})`", path.display() )); } else { warnings.push(format!( "[{}] future-incompatibility: `cfg({e})` is deprecated as `{name}` is a keyword \ and not an identifier and should not have have been accepted in this position.\n \ - | this was previously accepted by Cargo but is being phased out; it will become a hard error in a future release!", + | this was previously accepted by Cargo but is being phased out; it will become a hard error in a future release!\n \ + |\n \ + | help: use raw-idents instead: `cfg(r#{name})`", path.display() )); } diff --git a/tests/testsuite/cfg.rs b/tests/testsuite/cfg.rs index f3c852bddb5f..26ae8fa088f4 100644 --- a/tests/testsuite/cfg.rs +++ b/tests/testsuite/cfg.rs @@ -544,11 +544,6 @@ fn cfg_raw_idents() { p.cargo("check") .with_stderr_data(str![[r#" -[WARNING] [[ROOT]/foo/Cargo.toml] future-incompatibility: the meaning of `cfg(r#true)` will change in the future - | Cargo is erroneously allowing `cfg(true)` and `cfg(false)`, but both forms are interpreted as false unless manually overridden with `--cfg`. - | In the future these will be built-in defines that will have the corresponding true/false value. - | It is recommended to avoid using these configs until they are properly supported. - | See for more information. [LOCKING] 1 package to latest compatible version [CHECKING] foo v0.1.0 ([ROOT]/foo) [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s @@ -648,11 +643,15 @@ fn cfg_keywords() { | In the future these will be built-in defines that will have the corresponding true/false value. | It is recommended to avoid using these configs until they are properly supported. | See for more information. + | + | [HELP] use raw-idents instead: `cfg(r#true)` [WARNING] [.cargo/config.toml] future-incompatibility: the meaning of `cfg(false)` will change in the future | Cargo is erroneously allowing `cfg(true)` and `cfg(false)`, but both forms are interpreted as false unless manually overridden with `--cfg`. | In the future these will be built-in defines that will have the corresponding true/false value. | It is recommended to avoid using these configs until they are properly supported. | See for more information. + | + | [HELP] use raw-idents instead: `cfg(r#false)` [LOCKING] 1 package to latest compatible version [CHECKING] foo v0.1.0 ([ROOT]/foo) [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s