Skip to content

Commit e40ca12

Browse files
authored
Merge pull request #2993 from kinnison/fix-2982
(toolchain): Toolchain names must not be empty
2 parents f94717b + ce4027a commit e40ca12

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,10 @@ impl Cfg {
457457
})?;
458458
}
459459

460+
if name.is_empty() {
461+
anyhow::bail!("toolchain names must not be empty");
462+
}
463+
460464
Toolchain::from(self, name)
461465
}
462466

tests/cli-v2.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,19 @@ fn add_target_custom_toolchain() {
842842
});
843843
}
844844

845+
#[test]
846+
fn cannot_add_empty_named_custom_toolchain() {
847+
setup(&|config| {
848+
let path = config.customdir.join("custom-1");
849+
let path = path.to_string_lossy();
850+
expect_err(
851+
config,
852+
&["rustup", "toolchain", "link", "", &path],
853+
"toolchain names must not be empty",
854+
);
855+
});
856+
}
857+
845858
#[test]
846859
fn add_target_again() {
847860
setup(&|config| {

0 commit comments

Comments
 (0)