From 3f930306140d7ec6ad0daed4884f7c8c85a682d2 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Sat, 17 Jun 2023 11:01:02 -0500 Subject: [PATCH] fix(embedded): Don't auto-discover build.rs files With #12268, we moved the manifest root to be the scripts parent directory, making it so auto-discovery might pick some things up. We previously ensured `auto*` don't pick things up but missed `build.rs` This is now addressed. --- src/cargo/util/toml/embedded.rs | 5 +++++ tests/testsuite/script.rs | 13 +++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) 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 44213f8fc40..fccb685cc51 100644 --- a/tests/testsuite/script.rs +++ b/tests/testsuite/script.rs @@ -523,11 +523,16 @@ fn main() { p.cargo("-Zscript script.rs --help") .masquerade_as_nightly_cargo(&["script"]) - .with_status(101) - .with_stdout(r#""#) - .with_stderr_contains( + .with_stdout( + r#"Hello world! +"#, + ) + .with_stderr( "\ -[ERROR] could not compile `script` (build script) due to previous error +[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();