@@ -725,13 +725,26 @@ impl BuildOutput {
725
725
fn check_minimum_supported_rust_version_for_new_syntax (
726
726
pkg_descr : & str ,
727
727
msrv : & Option < RustVersion > ,
728
+ key : & str ,
728
729
) -> CargoResult < ( ) > {
729
730
if let Some ( msrv) = msrv {
730
731
let new_syntax_added_in = RustVersion :: from_str ( "1.77.0" ) ?;
731
732
if !new_syntax_added_in. is_compatible_with ( msrv. as_partial ( ) ) {
733
+ let prefix = format ! ( "{key}=" ) ;
734
+
735
+ let old_syntax_suggestion = RESERVED_PREFIXES
736
+ . contains ( & & * prefix)
737
+ . then ( || {
738
+ format ! (
739
+ "Consider using the old `cargo:` syntax in front of `{prefix}`.\n "
740
+ )
741
+ } )
742
+ . unwrap_or_default ( ) ;
743
+
732
744
bail ! (
733
745
"the `cargo::` syntax for build script output instructions was added in \
734
746
Rust 1.77.0, but the minimum supported Rust version of `{pkg_descr}` is {msrv}.\n \
747
+ {old_syntax_suggestion}\
735
748
{DOCS_LINK_SUGGESTION}"
736
749
) ;
737
750
}
@@ -793,9 +806,10 @@ impl BuildOutput {
793
806
} ;
794
807
let mut old_syntax = false ;
795
808
let ( key, value) = if let Some ( data) = line. strip_prefix ( "cargo::" ) {
796
- check_minimum_supported_rust_version_for_new_syntax ( pkg_descr, msrv) ?;
797
809
// For instance, `cargo::rustc-flags=foo` or `cargo::metadata=foo=bar`.
798
- parse_directive ( whence. as_str ( ) , line, data, old_syntax) ?
810
+ let ( key, value) = parse_directive ( whence. as_str ( ) , line, data, old_syntax) ?;
811
+ check_minimum_supported_rust_version_for_new_syntax ( pkg_descr, msrv, key) ?;
812
+ ( key, value)
799
813
} else if let Some ( data) = line. strip_prefix ( "cargo:" ) {
800
814
old_syntax = true ;
801
815
// For instance, `cargo:rustc-flags=foo`.
0 commit comments