Skip to content

Commit

Permalink
Merge pull request #1787 from Glamhoth/default_fix
Browse files Browse the repository at this point in the history
Fixed panic when no toolchain was configured
  • Loading branch information
kinnison authored Apr 23, 2019
2 parents 72d4442 + 44d1f83 commit cdc1489
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,11 @@ impl Cfg {
}

pub fn get_default(&self) -> Result<String> {
self.settings_file
.with(|s| Ok(s.default_toolchain.clone().unwrap()))
self.settings_file.with(|s| {
s.default_toolchain
.clone()
.ok_or_else(|| "no default toolchain configured".into())
})
}

pub fn list_toolchains(&self) -> Result<Vec<String>> {
Expand Down
11 changes: 11 additions & 0 deletions tests/cli-misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,17 @@ fn toolchains_are_resolved_early() {
});
}

#[test]
fn no_panic_on_default_toolchain_missing() {
setup(&|config| {
expect_err(
config,
&["rustup", "default"],
"no default toolchain configured",
);
});
}

// #190
#[test]
fn proxies_pass_empty_args() {
Expand Down

0 comments on commit cdc1489

Please sign in to comment.