From 08f06d8ad550134a11f2a83cb188bfb7fd3d1de4 Mon Sep 17 00:00:00 2001 From: "Filip (Glamhoth) Demski" Date: Mon, 22 Apr 2019 20:09:27 +0200 Subject: [PATCH 1/2] Fixed panic when no toolchain was configured --- src/config.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/config.rs b/src/config.rs index 3b6ce85c44..8fa7b7a80d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -344,8 +344,11 @@ impl Cfg { } pub fn get_default(&self) -> Result { - 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> { From 44d1f83c450e73bde0077b18ec0c54dbe9765f32 Mon Sep 17 00:00:00 2001 From: "Filip (Glamhoth) Demski" Date: Tue, 23 Apr 2019 13:04:23 +0200 Subject: [PATCH 2/2] Testing no default toolchain configured --- tests/cli-misc.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/cli-misc.rs b/tests/cli-misc.rs index 2d30dc7498..3a6c7f70fa 100644 --- a/tests/cli-misc.rs +++ b/tests/cli-misc.rs @@ -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() {