Skip to content

Commit

Permalink
fix(embedded): Don't generate empty package names
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jul 11, 2023
1 parent 87be661 commit 7d4e39c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/cargo/util/restricted_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ pub fn sanitize_package_name(name: &str, placeholder: char) -> String {
slug.push(placeholder);
}
}
if slug.is_empty() {
slug.push_str("package");
}
slug
}

Expand Down
13 changes: 8 additions & 5 deletions tests/testsuite/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,13 +574,16 @@ fn test_name_is_number() {

p.cargo("-Zscript -v 42.rs")
.masquerade_as_nightly_cargo(&["script"])
.with_status(101)
.with_stdout(
r#"bin: [..]/debug/package[EXE]
args: []
"#,
)
.with_stderr(
r#"[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
[ERROR] failed to parse manifest at `[ROOT]/foo/42.rs`
Caused by:
package name cannot be an empty string
[COMPILING] package v0.0.0 ([ROOT]/foo)
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
[RUNNING] `[..]/debug/package[EXE]`
"#,
)
.run();
Expand Down

0 comments on commit 7d4e39c

Please sign in to comment.