diff --git a/src/cargo/core/compiler/custom_build.rs b/src/cargo/core/compiler/custom_build.rs index 874b08102f76..cdde79501ed6 100644 --- a/src/cargo/core/compiler/custom_build.rs +++ b/src/cargo/core/compiler/custom_build.rs @@ -737,10 +737,12 @@ impl BuildOutput { let new_syntax_added_in = RustVersion::from_str("1.77.0")?; if !new_syntax_added_in.is_compatible_with(msrv.as_partial()) { let old_syntax_suggestion = if has_reserved_prefix(flag) { - format!("Consider using the old `cargo:` syntax in front of `{flag}`.\n") + format!( + "Switch to the old `cargo:{flag}` syntax (note the single colon).\n" + ) } else if flag.starts_with("metadata=") { let old_format_flag = flag.strip_prefix("metadata=").unwrap(); - format!("Consider using the old `cargo:{old_format_flag}` syntax instead of `cargo::{flag}` (note the single colon).\n") + format!("Switch to the old `cargo:{old_format_flag}` syntax instead of `cargo::{flag}` (note the single colon).\n") } else { String::new() }; diff --git a/tests/testsuite/build_script.rs b/tests/testsuite/build_script.rs index 367ae3465226..ef76309233b6 100644 --- a/tests/testsuite/build_script.rs +++ b/tests/testsuite/build_script.rs @@ -5501,7 +5501,7 @@ fn test_new_syntax_with_old_msrv() { [COMPILING] foo [..] [ERROR] the `cargo::` syntax for build script output instructions was added in Rust 1.77.0, \ but the minimum supported Rust version of `foo v0.5.0 ([ROOT]/foo)` is 1.60.0. -Consider using the old `cargo:foo=bar` syntax instead of `cargo::metadata=foo=bar` (note the single colon). +Switch to the old `cargo:foo=bar` syntax instead of `cargo::metadata=foo=bar` (note the single colon). See https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script \ for more information about build script outputs. ", @@ -5542,7 +5542,7 @@ fn test_new_syntax_with_old_msrv_and_reserved_prefix() { [COMPILING] foo [..] [ERROR] the `cargo::` syntax for build script output instructions was added in Rust 1.77.0, \ but the minimum supported Rust version of `foo v0.5.0 ([ROOT]/foo)` is 1.60.0. -Consider using the old `cargo:` syntax in front of `rustc-check-cfg=cfg(foo)`. +Switch to the old `cargo:rustc-check-cfg=cfg(foo)` syntax (note the single colon). See https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script \ for more information about build script outputs. ",