diff --git a/src/cargo/util/toml/embedded.rs b/src/cargo/util/toml/embedded.rs index 708500544d7..8e41010b43e 100644 --- a/src/cargo/util/toml/embedded.rs +++ b/src/cargo/util/toml/embedded.rs @@ -89,6 +89,9 @@ fn expand_manifest_( )); toml::Value::String(DEFAULT_EDITION.to_string()) }); + package + .entry("build".to_owned()) + .or_insert_with(|| toml::Value::Boolean(false)); package .entry("publish".to_owned()) .or_insert_with(|| toml::Value::Boolean(DEFAULT_PUBLISH)); @@ -491,6 +494,7 @@ autobenches = false autobins = false autoexamples = false autotests = false +build = false edition = "2021" name = "test-" publish = false @@ -520,6 +524,7 @@ autobenches = false autobins = false autoexamples = false autotests = false +build = false edition = "2021" name = "test-" publish = false diff --git a/tests/testsuite/script.rs b/tests/testsuite/script.rs index d4f343be644..fccb685cc51 100644 --- a/tests/testsuite/script.rs +++ b/tests/testsuite/script.rs @@ -509,6 +509,35 @@ fn main() { .run(); } +#[cargo_test] +fn test_no_build_rs() { + let script = r#"#!/usr/bin/env cargo + +fn main() { + println!("Hello world!"); +}"#; + let p = cargo_test_support::project() + .file("script.rs", script) + .file("build.rs", "broken") + .build(); + + p.cargo("-Zscript script.rs --help") + .masquerade_as_nightly_cargo(&["script"]) + .with_stdout( + r#"Hello world! +"#, + ) + .with_stderr( + "\ +[WARNING] `package.edition` is unspecifiead, defaulting to `2021` +[COMPILING] script v0.0.0 ([ROOT]/foo) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s +[RUNNING] `[..]/debug/script[EXE] --help` +", + ) + .run(); +} + #[cargo_test] fn test_no_autobins() { let script = r#"#!/usr/bin/env cargo