Skip to content

Commit e05b98b

Browse files
committed
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 <[email protected]>
1 parent c39e791 commit e05b98b

File tree

6 files changed

+17
-9
lines changed

6 files changed

+17
-9
lines changed

src/rustup-dist/src/dist.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ pub fn update_from_dist_<'a>(
556556
force_update,
557557
&download,
558558
download.notify_handler.clone(),
559+
&toolchain.manifest_name(),
559560
)? {
560561
UpdateStatus::Unchanged => Ok(None),
561562
UpdateStatus::Changed => Ok(Some(hash)),

src/rustup-dist/src/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ error_chain! {
107107
description("missing package for the target of a rename")
108108
display("server sent a broken manifest: missing package for the target of a rename {}", name)
109109
}
110-
RequestedComponentsUnavailable(c: Vec<Component>, manifest: Manifest) {
110+
RequestedComponentsUnavailable(c: Vec<Component>, manifest: Manifest, toolchain: String) {
111111
description("some requested components are unavailable to download")
112-
display("{}", component_unavailable_msg(&c, &manifest))
112+
display("{} for channel '{}'", component_unavailable_msg(&c, &manifest), toolchain)
113113
}
114114
}
115115
}

src/rustup-dist/src/manifestation.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ impl Manifestation {
111111
force_update: bool,
112112
download_cfg: &DownloadCfg<'_>,
113113
notify_handler: &dyn Fn(Notification<'_>),
114+
toolchain_str: &str,
114115
) -> Result<UpdateStatus> {
115116
// Some vars we're going to need a few times
116117
let temp_cfg = download_cfg.temp_cfg;
@@ -126,10 +127,10 @@ impl Manifestation {
126127
}
127128

128129
// Make sure we don't accidentally uninstall the essential components! (see #1297)
129-
update.missing_essential_components(&self.target_triple, new_manifest)?;
130+
update.missing_essential_components(&self.target_triple, new_manifest, toolchain_str)?;
130131

131132
// Validate that the requested components are available
132-
match update.unavailable_components(new_manifest) {
133+
match update.unavailable_components(new_manifest, toolchain_str) {
133134
Ok(_) => {}
134135
_ if force_update => {}
135136
Err(e) => return Err(e),
@@ -594,6 +595,7 @@ impl Update {
594595
&self,
595596
target_triple: &TargetTriple,
596597
manifest: &Manifest,
598+
toolchain_str: &str,
597599
) -> Result<()> {
598600
let missing_essential_components = ["rustc", "cargo"]
599601
.iter()
@@ -614,14 +616,15 @@ impl Update {
614616
return Err(ErrorKind::RequestedComponentsUnavailable(
615617
missing_essential_components,
616618
manifest.clone(),
619+
toolchain_str.to_owned(),
617620
)
618621
.into());
619622
}
620623

621624
Ok(())
622625
}
623626

624-
fn unavailable_components(&self, new_manifest: &Manifest) -> Result<()> {
627+
fn unavailable_components(&self, new_manifest: &Manifest, toolchain_str: &str) -> Result<()> {
625628
let mut unavailable_components: Vec<Component> = self
626629
.components_to_install
627630
.iter()
@@ -642,6 +645,7 @@ impl Update {
642645
return Err(ErrorKind::RequestedComponentsUnavailable(
643646
unavailable_components,
644647
new_manifest.clone(),
648+
toolchain_str.to_owned(),
645649
)
646650
.into());
647651
}

src/rustup-dist/tests/dist.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ fn update_from_dist_(
422422
force_update,
423423
download_cfg,
424424
download_cfg.notify_handler.clone(),
425+
&toolchain.to_string(),
425426
)
426427
}
427428

src/rustup/toolchain.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@ impl<'a> Toolchain<'a> {
594594
false,
595595
&self.download_cfg(),
596596
self.download_cfg().notify_handler.clone(),
597+
&toolchain.manifest_name(),
597598
)?;
598599

599600
Ok(())
@@ -663,6 +664,7 @@ impl<'a> Toolchain<'a> {
663664
false,
664665
&self.download_cfg(),
665666
self.download_cfg().notify_handler.clone(),
667+
&toolchain.manifest_name(),
666668
)?;
667669

668670
Ok(())

tests/cli-v2.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -836,8 +836,8 @@ fn update_unavailable_std() {
836836
config,
837837
&["rustup", "update", "nightly", "--no-self-update"],
838838
&format!(
839-
"component 'rust-std' for target '{}' is unavailable for download",
840-
trip
839+
"component 'rust-std' for target '{}' is unavailable for download for channel 'nightly'",
840+
trip,
841841
),
842842
);
843843
});
@@ -864,8 +864,8 @@ fn update_unavailable_force() {
864864
config,
865865
&["rustup", "update", "nightly", "--no-self-update"],
866866
&format!(
867-
"component 'rls' for target '{}' is unavailable for download",
868-
trip
867+
"component 'rls' for target '{}' is unavailable for download for channel 'nightly'",
868+
trip,
869869
),
870870
);
871871
expect_ok(

0 commit comments

Comments
 (0)