Skip to content

Commit b00064c

Browse files
committed
fix(script): Default bin.name to package.name
The current behavior breaks from how implicit bins normally work when `package.name` is set. When it isn't set, they were using the same logic, so that should be fine.
1 parent 79c8c64 commit b00064c

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

src/cargo/util/toml/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,7 @@ fn normalize_toml(
379379
warnings,
380380
)?;
381381
let original_toml_bin = if is_embedded {
382-
let manifest_file_stem = manifest_file
383-
.file_stem()
384-
.expect("file name enforced previously");
385-
let name = embedded::sanitize_name(manifest_file_stem.to_string_lossy().as_ref());
382+
let name = package_name.as_ref().to_owned();
386383
let manifest_file_name = manifest_file
387384
.file_name()
388385
.expect("file name enforced previously");

tests/testsuite/script/cargo.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -724,17 +724,14 @@ fn test () {}
724724

725725
p.cargo("-Zscript -v deps.rs")
726726
.masquerade_as_nightly_cargo(&["script"])
727-
.with_stdout_data(str![[r#"
728-
current_exe: [ROOT]/home/.cargo/target/[HASH]/debug/deps-[EXE]
729-
arg0: [..]
730-
args: []
731-
732-
"#]])
727+
.with_status(101)
728+
.with_stdout_data(str![""])
733729
.with_stderr_data(str![[r#"
734730
[WARNING] `package.edition` is unspecified, defaulting to `2024`
735-
[COMPILING] deps v0.0.0 ([ROOT]/foo/deps.rs)
736-
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
737-
[RUNNING] `[ROOT]/home/.cargo/target/[HASH]/debug/deps-[EXE]`
731+
[ERROR] failed to parse manifest at `[ROOT]/foo/deps.rs`
732+
733+
Caused by:
734+
the binary target name `deps` is forbidden, it conflicts with cargo's build directory names
738735
739736
"#]])
740737
.run();

0 commit comments

Comments
 (0)