fix(dist/manifestation): use full toolchain name in Update::unavailable_components()

This commit is contained in:
rami3l
2026-03-22 10:22:38 +01:00
parent 52fa2fc6c9
commit 85653a3d5b
5 changed files with 28 additions and 52 deletions

View File

@@ -24,7 +24,7 @@ use tracing::{debug, info, warn};
use crate::{
diskio::{Executor, IO_CHUNK_SIZE, get_executor, unpack_ram},
dist::{
DEFAULT_DIST_SERVER, Profile, TargetTriple,
DEFAULT_DIST_SERVER, Profile, TargetTriple, ToolchainDesc,
component::{Components, DirectoryPackage, Transaction},
config::Config,
download::{DownloadCfg, DownloadStatus, File},
@@ -120,7 +120,7 @@ impl Manifestation {
changes: Changes,
force_update: bool,
download_cfg: &DownloadCfg<'_>,
toolchain_str: String,
toolchain: &ToolchainDesc,
implicit_modify: bool,
) -> Result<UpdateStatus> {
// Some vars we're going to need a few times
@@ -137,7 +137,7 @@ impl Manifestation {
}
// Validate that the requested components are available
if let Err(e) = update.unavailable_components(&new_manifest, &toolchain_str) {
if let Err(e) = update.unavailable_components(&new_manifest, toolchain) {
if !force_update {
return Err(e);
}
@@ -702,7 +702,11 @@ impl Update {
self.components_to_uninstall.is_empty() && self.components_to_install.is_empty()
}
fn unavailable_components(&self, new_manifest: &Manifest, toolchain_str: &str) -> Result<()> {
fn unavailable_components(
&self,
new_manifest: &Manifest,
toolchain: &ToolchainDesc,
) -> Result<()> {
let mut unavailable_components: Vec<Component> = self
.components_to_install
.iter()
@@ -723,7 +727,7 @@ impl Update {
bail!(RustupError::RequestedComponentsUnavailable {
components: unavailable_components,
manifest: new_manifest.clone(),
toolchain: toolchain_str.to_owned(),
toolchain: toolchain.to_string(),
});
}

View File

@@ -509,14 +509,7 @@ impl TestContext {
};
manifestation
.update(
manifest,
changes,
force,
&dl_cfg,
self.toolchain.manifest_name(),
true,
)
.update(manifest, changes, force, &dl_cfg, &self.toolchain, true)
.await
}
@@ -660,7 +653,7 @@ async fn unavailable_component() {
manifest,
toolchain,
}) => {
assert_eq!(toolchain, "nightly");
assert_eq!(toolchain, "nightly-x86_64-apple-darwin");
let descriptions = components
.iter()
.map(|c| manifest.description(c))
@@ -705,7 +698,7 @@ async fn unavailable_component_from_profile() {
manifest,
toolchain,
}) => {
assert_eq!(toolchain, "nightly");
assert_eq!(toolchain, "nightly-x86_64-apple-darwin");
let descriptions = components
.iter()
.map(|c| manifest.description(c))
@@ -759,7 +752,7 @@ async fn removed_component() {
manifest,
toolchain,
}) => {
assert_eq!(toolchain, "nightly");
assert_eq!(toolchain, "nightly-x86_64-apple-darwin");
let descriptions = components
.iter()
.map(|c| manifest.description(c))
@@ -823,7 +816,7 @@ async fn unavailable_components_is_target() {
manifest,
toolchain,
}) => {
assert_eq!(toolchain, "nightly");
assert_eq!(toolchain, "nightly-x86_64-apple-darwin");
let descriptions = components
.iter()
.map(|c| manifest.description(c))
@@ -888,7 +881,7 @@ async fn unavailable_components_with_same_target() {
manifest,
toolchain,
}) => {
assert_eq!(toolchain, "nightly");
assert_eq!(toolchain, "nightly-x86_64-apple-darwin");
let descriptions = components
.iter()
.map(|c| manifest.description(c))

9
src/dist/mod.rs vendored
View File

@@ -1199,14 +1199,7 @@ async fn try_update_from_dist_(
fetched.clone_from(&m.date);
return match manifestation
.update(
m,
changes,
force_update,
download,
toolchain.manifest_name(),
true,
)
.update(m, changes, force_update, download, toolchain, true)
.await
{
Ok(status) => match status {

View File

@@ -121,14 +121,7 @@ impl<'a> DistributableToolchain<'a> {
let download_cfg = DownloadCfg::new(self.toolchain.cfg);
manifestation
.update(
manifest,
changes,
false,
&download_cfg,
self.desc.manifest_name(),
false,
)
.update(manifest, changes, false, &download_cfg, &self.desc, false)
.await?;
Ok(())
@@ -432,14 +425,7 @@ impl<'a> DistributableToolchain<'a> {
let download_cfg = DownloadCfg::new(self.toolchain.cfg);
manifestation
.update(
manifest,
changes,
false,
&download_cfg,
self.desc.manifest_name(),
false,
)
.update(manifest, changes, false, &download_cfg, &self.desc, false)
.await?;
Ok(())

View File

@@ -1952,7 +1952,7 @@ async fn update_unavailable_std() {
.await
.with_stderr(snapbox::str![[r#"
...
error: component 'rust-std' for target '[HOST_TRIPLE]' is unavailable for download for channel 'nightly'
error: component 'rust-std' for target '[HOST_TRIPLE]' is unavailable for download for channel 'nightly-[HOST_TRIPLE]'
...
"#]])
.is_err();
@@ -1971,7 +1971,7 @@ async fn add_missing_component() {
.await
.with_stderr(snapbox::str![[r#"
...
error: component 'rls' for target '[HOST_TRIPLE]' is unavailable for download for channel 'nightly'
error: component 'rls' for target '[HOST_TRIPLE]' is unavailable for download for channel 'nightly-[HOST_TRIPLE]'
note: sometimes not all components are available in any given nightly
...
"#]])
@@ -1994,10 +1994,10 @@ async fn add_toolchain_with_missing_component() {
.await
.with_stderr(snapbox::str![[r#"
...
error: component 'rust-std' for target '[HOST_TRIPLE]' is unavailable for download for channel 'nightly'
error: component 'rust-std' for target '[HOST_TRIPLE]' is unavailable for download for channel 'nightly-[HOST_TRIPLE]'
note: sometimes not all components are available in any given nightly
help: if you don't need these components, you could try a minimal installation with:
help: rustup toolchain add nightly --profile minimal
help: rustup toolchain add nightly-[HOST_TRIPLE] --profile minimal
help: if you require these components, please install and use the latest successfully built version,
help: which you can find at <https://rust-lang.github.io/rustup-components-history>
help: after determining the correct date, install it with a command such as:
@@ -2020,10 +2020,10 @@ async fn add_toolchain_with_missing_components() {
.await
.with_stderr(snapbox::str![[r#"
...
error: some components are unavailable for download for channel 'nightly': 'cargo' for target '[HOST_TRIPLE]', 'rust-std' for target '[HOST_TRIPLE]'
error: some components are unavailable for download for channel 'nightly-[HOST_TRIPLE]': 'cargo' for target '[HOST_TRIPLE]', 'rust-std' for target '[HOST_TRIPLE]'
note: sometimes not all components are available in any given nightly
help: if you don't need these components, you could try a minimal installation with:
help: rustup toolchain add nightly --profile minimal
help: rustup toolchain add nightly-[HOST_TRIPLE] --profile minimal
help: if you require these components, please install and use the latest successfully built version,
help: which you can find at <https://rust-lang.github.io/rustup-components-history>
help: after determining the correct date, install it with a command such as:
@@ -2068,7 +2068,7 @@ async fn update_removed_component_toolchain() {
.await
.with_stderr(snapbox::str![[r#"
...
error: component 'rls' for target '[HOST_TRIPLE]' is unavailable for download for channel 'stable'
error: component 'rls' for target '[HOST_TRIPLE]' is unavailable for download for channel 'stable-[HOST_TRIPLE]'
One or many components listed above might have been permanently removed from newer versions
of the official Rust distribution due to deprecation.
...
@@ -2112,7 +2112,7 @@ async fn update_unavailable_force() {
.await
.with_stderr(snapbox::str![[r#"
...
error: component 'rls' for target '[HOST_TRIPLE]' is unavailable for download for channel 'nightly'
error: component 'rls' for target '[HOST_TRIPLE]' is unavailable for download for channel 'nightly-[HOST_TRIPLE]'
...
"#]])
.is_err();
@@ -2429,7 +2429,7 @@ async fn test_complete_profile_skips_missing_when_forced() {
.await
.with_stderr(snapbox::str![[r#"
...
error: component 'rls' for target '[HOST_TRIPLE]' is unavailable for download for channel 'nightly'
error: component 'rls' for target '[HOST_TRIPLE]' is unavailable for download for channel 'nightly-[HOST_TRIPLE]'
...
"#]])
.is_err();
@@ -2522,7 +2522,7 @@ async fn install_allow_downgrade() {
.await
.with_stderr(snapbox::str![[r#"
...
error: component 'rls' for target '[HOST_TRIPLE]' is unavailable for download for channel 'nightly'
error: component 'rls' for target '[HOST_TRIPLE]' is unavailable for download for channel 'nightly-[HOST_TRIPLE]'
...
"#]])
.is_err();