Skip to content

Thread toolchain through to error message #1616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/rustup-dist/src/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
4 changes: 2 additions & 2 deletions src/rustup-dist/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Component>, manifest: Manifest) {
RequestedComponentsUnavailable(c: Vec<Component>, 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)
}
}
}
Expand Down
10 changes: 7 additions & 3 deletions src/rustup-dist/src/manifestation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ impl Manifestation {
force_update: bool,
download_cfg: &DownloadCfg<'_>,
notify_handler: &dyn Fn(Notification<'_>),
toolchain_str: &str,
) -> Result<UpdateStatus> {
// Some vars we're going to need a few times
let temp_cfg = download_cfg.temp_cfg;
Expand All @@ -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),
Expand Down Expand Up @@ -594,6 +595,7 @@ impl Update {
&self,
target_triple: &TargetTriple,
manifest: &Manifest,
toolchain_str: &str,
) -> Result<()> {
let missing_essential_components = ["rustc", "cargo"]
.iter()
Expand All @@ -614,14 +616,15 @@ impl Update {
return Err(ErrorKind::RequestedComponentsUnavailable(
missing_essential_components,
manifest.clone(),
toolchain_str.to_owned(),
)
.into());
}

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<Component> = self
.components_to_install
.iter()
Expand All @@ -642,6 +645,7 @@ impl Update {
return Err(ErrorKind::RequestedComponentsUnavailable(
unavailable_components,
new_manifest.clone(),
toolchain_str.to_owned(),
)
.into());
}
Expand Down
1 change: 1 addition & 0 deletions src/rustup-dist/tests/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ fn update_from_dist_(
force_update,
download_cfg,
download_cfg.notify_handler.clone(),
&toolchain.to_string(),
)
}

Expand Down
2 changes: 2 additions & 0 deletions src/rustup/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ impl<'a> Toolchain<'a> {
false,
&self.download_cfg(),
self.download_cfg().notify_handler.clone(),
&toolchain.manifest_name(),
)?;

Ok(())
Expand Down Expand Up @@ -663,6 +664,7 @@ impl<'a> Toolchain<'a> {
false,
&self.download_cfg(),
self.download_cfg().notify_handler.clone(),
&toolchain.manifest_name(),
)?;

Ok(())
Expand Down
8 changes: 4 additions & 4 deletions tests/cli-v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
);
});
Expand All @@ -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(
Expand Down