From e05b98ba162c6743567ade9b19bc00f5ed125d16 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Fri, 1 Mar 2019 21:02:27 +0000 Subject: [PATCH] Thread toolchain through to error message In the component-unavailable error case, we need to report the full toolchain rather than just the component and target name. This threads it through and reports it in the error message. Fixes: #1596 Signed-off-by: Daniel Silverstone --- src/rustup-dist/src/dist.rs | 1 + src/rustup-dist/src/errors.rs | 4 ++-- src/rustup-dist/src/manifestation.rs | 10 +++++++--- src/rustup-dist/tests/dist.rs | 1 + src/rustup/toolchain.rs | 2 ++ tests/cli-v2.rs | 8 ++++---- 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/rustup-dist/src/dist.rs b/src/rustup-dist/src/dist.rs index 2de0e5ddcc..7adec48186 100644 --- a/src/rustup-dist/src/dist.rs +++ b/src/rustup-dist/src/dist.rs @@ -556,6 +556,7 @@ pub fn update_from_dist_<'a>( force_update, &download, download.notify_handler.clone(), + &toolchain.manifest_name(), )? { UpdateStatus::Unchanged => Ok(None), UpdateStatus::Changed => Ok(Some(hash)), diff --git a/src/rustup-dist/src/errors.rs b/src/rustup-dist/src/errors.rs index 7dbbf8092b..233af8e828 100644 --- a/src/rustup-dist/src/errors.rs +++ b/src/rustup-dist/src/errors.rs @@ -107,9 +107,9 @@ error_chain! { description("missing package for the target of a rename") display("server sent a broken manifest: missing package for the target of a rename {}", name) } - RequestedComponentsUnavailable(c: Vec, manifest: Manifest) { + RequestedComponentsUnavailable(c: Vec, manifest: Manifest, toolchain: String) { description("some requested components are unavailable to download") - display("{}", component_unavailable_msg(&c, &manifest)) + display("{} for channel '{}'", component_unavailable_msg(&c, &manifest), toolchain) } } } diff --git a/src/rustup-dist/src/manifestation.rs b/src/rustup-dist/src/manifestation.rs index 36fed4db69..2a34b55235 100644 --- a/src/rustup-dist/src/manifestation.rs +++ b/src/rustup-dist/src/manifestation.rs @@ -111,6 +111,7 @@ impl Manifestation { force_update: bool, download_cfg: &DownloadCfg<'_>, notify_handler: &dyn Fn(Notification<'_>), + toolchain_str: &str, ) -> Result { // Some vars we're going to need a few times let temp_cfg = download_cfg.temp_cfg; @@ -126,10 +127,10 @@ impl Manifestation { } // Make sure we don't accidentally uninstall the essential components! (see #1297) - update.missing_essential_components(&self.target_triple, new_manifest)?; + update.missing_essential_components(&self.target_triple, new_manifest, toolchain_str)?; // Validate that the requested components are available - match update.unavailable_components(new_manifest) { + match update.unavailable_components(new_manifest, toolchain_str) { Ok(_) => {} _ if force_update => {} Err(e) => return Err(e), @@ -594,6 +595,7 @@ impl Update { &self, target_triple: &TargetTriple, manifest: &Manifest, + toolchain_str: &str, ) -> Result<()> { let missing_essential_components = ["rustc", "cargo"] .iter() @@ -614,6 +616,7 @@ impl Update { return Err(ErrorKind::RequestedComponentsUnavailable( missing_essential_components, manifest.clone(), + toolchain_str.to_owned(), ) .into()); } @@ -621,7 +624,7 @@ impl Update { Ok(()) } - fn unavailable_components(&self, new_manifest: &Manifest) -> Result<()> { + fn unavailable_components(&self, new_manifest: &Manifest, toolchain_str: &str) -> Result<()> { let mut unavailable_components: Vec = self .components_to_install .iter() @@ -642,6 +645,7 @@ impl Update { return Err(ErrorKind::RequestedComponentsUnavailable( unavailable_components, new_manifest.clone(), + toolchain_str.to_owned(), ) .into()); } diff --git a/src/rustup-dist/tests/dist.rs b/src/rustup-dist/tests/dist.rs index 192096bca9..6c0be8204d 100644 --- a/src/rustup-dist/tests/dist.rs +++ b/src/rustup-dist/tests/dist.rs @@ -422,6 +422,7 @@ fn update_from_dist_( force_update, download_cfg, download_cfg.notify_handler.clone(), + &toolchain.to_string(), ) } diff --git a/src/rustup/toolchain.rs b/src/rustup/toolchain.rs index cf78f782ed..f78630550f 100644 --- a/src/rustup/toolchain.rs +++ b/src/rustup/toolchain.rs @@ -594,6 +594,7 @@ impl<'a> Toolchain<'a> { false, &self.download_cfg(), self.download_cfg().notify_handler.clone(), + &toolchain.manifest_name(), )?; Ok(()) @@ -663,6 +664,7 @@ impl<'a> Toolchain<'a> { false, &self.download_cfg(), self.download_cfg().notify_handler.clone(), + &toolchain.manifest_name(), )?; Ok(()) diff --git a/tests/cli-v2.rs b/tests/cli-v2.rs index 0d893ac59b..3a900b8957 100644 --- a/tests/cli-v2.rs +++ b/tests/cli-v2.rs @@ -836,8 +836,8 @@ fn update_unavailable_std() { config, &["rustup", "update", "nightly", "--no-self-update"], &format!( - "component 'rust-std' for target '{}' is unavailable for download", - trip + "component 'rust-std' for target '{}' is unavailable for download for channel 'nightly'", + trip, ), ); }); @@ -864,8 +864,8 @@ fn update_unavailable_force() { config, &["rustup", "update", "nightly", "--no-self-update"], &format!( - "component 'rls' for target '{}' is unavailable for download", - trip + "component 'rls' for target '{}' is unavailable for download for channel 'nightly'", + trip, ), ); expect_ok(