Skip to content

Commit ba5ec68

Browse files
committed
fix: emit 1.77 syntax error only when msrv is incompatible
1 parent f70bfd3 commit ba5ec68

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

src/cargo/core/compiler/custom_build.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -724,10 +724,9 @@ impl BuildOutput {
724724
pkg_descr: &str,
725725
msrv: &Option<RustVersion>,
726726
) -> CargoResult<()> {
727-
let new_syntax_added_in = &RustVersion::from_str("1.77.0")?;
728-
729727
if let Some(msrv) = msrv {
730-
if msrv < new_syntax_added_in {
728+
let new_syntax_added_in = RustVersion::from_str("1.77.0")?;
729+
if !new_syntax_added_in.is_compatible_with(msrv.as_partial()) {
731730
bail!(
732731
"the `cargo::` syntax for build script output instructions was added in \
733732
Rust 1.77.0, but the minimum supported Rust version of `{pkg_descr}` is {msrv}.\n\

tests/testsuite/build_script.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5527,14 +5527,9 @@ fn test_new_syntax_with_compatible_partial_msrv() {
55275527
.build();
55285528

55295529
p.cargo("check")
5530-
.with_status(101)
55315530
.with_stderr_contains(
55325531
"\
55335532
[COMPILING] foo [..]
5534-
[ERROR] the `cargo::` syntax for build script output instructions was added in Rust 1.77.0, \
5535-
but the minimum supported Rust version of `foo v0.0.0 ([ROOT]/foo)` is 1.77.
5536-
See https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script \
5537-
for more information about build script outputs.
55385533
",
55395534
)
55405535
.run();

0 commit comments

Comments
 (0)