mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Auto merge of #13808 - weihanglo:buildscript-msrv, r=epage
fix: emit 1.77 syntax error only when msrv is incompatible
This commit is contained in:
commit
1dadee6d8b
@ -724,10 +724,9 @@ impl BuildOutput {
|
|||||||
pkg_descr: &str,
|
pkg_descr: &str,
|
||||||
msrv: &Option<RustVersion>,
|
msrv: &Option<RustVersion>,
|
||||||
) -> CargoResult<()> {
|
) -> CargoResult<()> {
|
||||||
let new_syntax_added_in = &RustVersion::from_str("1.77.0")?;
|
|
||||||
|
|
||||||
if let Some(msrv) = msrv {
|
if let Some(msrv) = msrv {
|
||||||
if msrv < new_syntax_added_in {
|
let new_syntax_added_in = RustVersion::from_str("1.77.0")?;
|
||||||
|
if !new_syntax_added_in.is_compatible_with(msrv.as_partial()) {
|
||||||
bail!(
|
bail!(
|
||||||
"the `cargo::` syntax for build script output instructions was added in \
|
"the `cargo::` syntax for build script output instructions was added in \
|
||||||
Rust 1.77.0, but the minimum supported Rust version of `{pkg_descr}` is {msrv}.\n\
|
Rust 1.77.0, but the minimum supported Rust version of `{pkg_descr}` is {msrv}.\n\
|
||||||
|
@ -5502,6 +5502,39 @@ for more information about build script outputs.
|
|||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cargo_test]
|
||||||
|
fn test_new_syntax_with_compatible_partial_msrv() {
|
||||||
|
let p = project()
|
||||||
|
.file(
|
||||||
|
"Cargo.toml",
|
||||||
|
r#"
|
||||||
|
[package]
|
||||||
|
name = "foo"
|
||||||
|
edition = "2015"
|
||||||
|
build = "build.rs"
|
||||||
|
rust-version = "1.77"
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.file("src/lib.rs", "")
|
||||||
|
.file(
|
||||||
|
"build.rs",
|
||||||
|
r#"
|
||||||
|
fn main() {
|
||||||
|
println!("cargo::metadata=foo=bar");
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
p.cargo("check")
|
||||||
|
.with_stderr_contains(
|
||||||
|
"\
|
||||||
|
[COMPILING] foo [..]
|
||||||
|
",
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
|
||||||
#[cargo_test]
|
#[cargo_test]
|
||||||
fn test_old_syntax_with_old_msrv() {
|
fn test_old_syntax_with_old_msrv() {
|
||||||
let p = project()
|
let p = project()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user