Skip to content

Commit

Permalink
Merge pull request #2993 from kinnison/fix-2982
Browse files Browse the repository at this point in the history
(toolchain): Toolchain names must not be empty
  • Loading branch information
Rustin170506 authored Oct 6, 2022
2 parents f94717b + ce4027a commit e40ca12
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 e40ca12

Please sign in to comment.