Skip to content

Commit 5c41426

Browse files
committed
WIP: 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 104c45e commit 5c41426

File tree

6 files changed

+19
-9
lines changed

6 files changed

+19
-9
lines changed

src/rustup-dist/src/dist.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ pub fn update_from_dist_<'a>(
542542
force_update,
543543
&download,
544544
download.notify_handler.clone(),
545+
&toolchain_str,
545546
)? {
546547
UpdateStatus::Unchanged => Ok(None),
547548
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
@@ -106,9 +106,9 @@ error_chain! {
106106
description("missing package for the target of a rename")
107107
display("server sent a broken manifest: missing package for the target of a rename {}", name)
108108
}
109-
RequestedComponentsUnavailable(c: Vec<Component>, manifest: Manifest) {
109+
RequestedComponentsUnavailable(c: Vec<Component>, manifest: Manifest, toolchain: String) {
110110
description("some requested components are unavailable to download")
111-
display("{}", component_unavailable_msg(&c, &manifest))
111+
display("{} for toolchain '{}'", component_unavailable_msg(&c, &manifest), toolchain)
112112
}
113113
}
114114
}

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: &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),
@@ -589,6 +590,7 @@ impl Update {
589590
&self,
590591
target_triple: &TargetTriple,
591592
manifest: &Manifest,
593+
toolchain_str: &str,
592594
) -> Result<()> {
593595
let missing_essential_components = ["rustc", "cargo"]
594596
.iter()
@@ -609,14 +611,15 @@ impl Update {
609611
return Err(ErrorKind::RequestedComponentsUnavailable(
610612
missing_essential_components,
611613
manifest.clone(),
614+
toolchain_str.to_owned(),
612615
)
613616
.into());
614617
}
615618

616619
Ok(())
617620
}
618621

619-
fn unavailable_components(&self, new_manifest: &Manifest) -> Result<()> {
622+
fn unavailable_components(&self, new_manifest: &Manifest, toolchain_str: &str) -> Result<()> {
620623
let mut unavailable_components: Vec<Component> = self
621624
.components_to_install
622625
.iter()
@@ -637,6 +640,7 @@ impl Update {
637640
return Err(ErrorKind::RequestedComponentsUnavailable(
638641
unavailable_components,
639642
new_manifest.clone(),
643+
toolchain_str.to_owned(),
640644
)
641645
.into());
642646
}

src/rustup-dist/tests/dist.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ fn update_from_dist_(
433433
force_update,
434434
download_cfg,
435435
download_cfg.notify_handler.clone(),
436+
&toolchain.to_string(),
436437
)
437438
}
438439

src/rustup/toolchain.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,7 @@ impl<'a> Toolchain<'a> {
678678
false,
679679
&self.download_cfg(),
680680
self.download_cfg().notify_handler.clone(),
681+
&toolchain.to_string(),
681682
)?;
682683

683684
Ok(())
@@ -747,6 +748,7 @@ impl<'a> Toolchain<'a> {
747748
false,
748749
&self.download_cfg(),
749750
self.download_cfg().notify_handler.clone(),
751+
&toolchain.to_string(),
750752
)?;
751753

752754
Ok(())

tests/cli-v2.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -841,8 +841,9 @@ fn update_unavailable_std() {
841841
config,
842842
&["rustup", "update", "nightly", "--no-self-update"],
843843
&format!(
844-
"component 'rust-std' for target '{}' is unavailable for download",
845-
trip
844+
"component 'rust-std' for target '{}' is unavailable for download for toolchain 'nightly-{}'",
845+
trip,
846+
trip,
846847
),
847848
);
848849
});
@@ -869,8 +870,9 @@ fn update_unavailable_force() {
869870
config,
870871
&["rustup", "update", "nightly", "--no-self-update"],
871872
&format!(
872-
"component 'rls' for target '{}' is unavailable for download",
873-
trip
873+
"component 'rls' for target '{}' is unavailable for download for toolchain 'nightly-{}'",
874+
trip,
875+
trip,
874876
),
875877
);
876878
expect_ok(

0 commit comments

Comments
 (0)