File tree 2 files changed +45
-1
lines changed
2 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -690,7 +690,20 @@ impl BuildOutput {
690
690
continue ;
691
691
}
692
692
let data = match iter. next ( ) {
693
- Some ( val) => val,
693
+ Some ( val) => {
694
+ if val. starts_with ( ":" ) {
695
+ // Line started with `cargo::`.
696
+ bail ! ( "invalid output in {}: `{}`\n \
697
+ Expected a line with `cargo:key=value`, \
698
+ but found `cargo::` instead.\n \
699
+ `cargo::` is reserved for future use or some way to indicate that there is a version mismatch \
700
+ between the build script and cargo, whether its because no MSRV was specified \
701
+ or someone was reading too new of documentation. \
702
+ See https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script \
703
+ for more information about build script outputs.", whence, line) ;
704
+ }
705
+ val
706
+ }
694
707
None => continue ,
695
708
} ;
696
709
Original file line number Diff line number Diff line change @@ -5140,6 +5140,37 @@ for more information about build script outputs.
5140
5140
. run ( ) ;
5141
5141
}
5142
5142
5143
+ #[ cargo_test]
5144
+ fn wrong_syntax_with_two_colons ( ) {
5145
+ let p = project ( )
5146
+ . file ( "src/lib.rs" , "" )
5147
+ . file (
5148
+ "build.rs" ,
5149
+ r#"
5150
+ fn main() {
5151
+ println!("cargo::foo=bar");
5152
+ }
5153
+ "# ,
5154
+ )
5155
+ . build ( ) ;
5156
+
5157
+ p. cargo ( "build" )
5158
+ . with_status ( 101 )
5159
+ . with_stderr (
5160
+ "\
5161
+ [COMPILING] foo [..]
5162
+ error: invalid output in build script of `foo v0.0.1 ([ROOT]/foo)`: `cargo::foo=bar`
5163
+ Expected a line with `cargo:key=value`, but found `cargo::` instead.
5164
+ `cargo::` is reserved for future use or some way to indicate that there is a version mismatch \
5165
+ between the build script and cargo, whether its because no MSRV was specified \
5166
+ or someone was reading too new of documentation. \
5167
+ See https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script \
5168
+ for more information about build script outputs.
5169
+ " ,
5170
+ )
5171
+ . run ( ) ;
5172
+ }
5173
+
5143
5174
#[ cargo_test]
5144
5175
fn custom_build_closes_stdin ( ) {
5145
5176
// Ensure stdin is closed to prevent deadlock.
You can’t perform that action at this time.
0 commit comments