Skip to content

Commit

Permalink
(toolchain): Toolchain names must not be empty
Browse files Browse the repository at this point in the history
This fixes a problem where if you did `toolchain link "" ...`
then the `toolchains` dir was broken.

This fixes #2982

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
  • Loading branch information
kinnison committed May 20, 2022
1 parent 3ced044 commit ce4027a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,10 @@ impl Cfg {
})?;
}

if name.is_empty() {
anyhow::bail!("toolchain names must not be empty");
}

Toolchain::from(self, name)
}

Expand Down
13 changes: 13 additions & 0 deletions tests/cli-v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,19 @@ fn add_target_custom_toolchain() {
});
}

#[test]
fn cannot_add_empty_named_custom_toolchain() {
setup(&|config| {
let path = config.customdir.join("custom-1");
let path = path.to_string_lossy();
expect_err(
config,
&["rustup", "toolchain", "link", "", &path],
"toolchain names must not be empty",
);
});
}

#[test]
fn add_target_again() {
setup(&|config| {
Expand Down

0 comments on commit ce4027a

Please sign in to comment.