Skip to content

Commit 769b99b

Browse files
authored
Merge pull request #1931 from kinnison/kinnison/unavailable-targets
Do not list unavailable targets
2 parents 17e46e0 + 82c92eb commit 769b99b

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/toolchain.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::config::Cfg;
2+
use crate::dist::dist::TargetTriple;
23
use crate::dist::dist::ToolchainDesc;
34
use crate::dist::download::DownloadCfg;
45
use crate::dist::manifest::Component;
@@ -529,6 +530,8 @@ impl<'a> Toolchain<'a> {
529530
.map(|c| c.components.contains(extension))
530531
.unwrap_or(false);
531532

533+
let extension_target = TargetTriple::new(&extension.target());
534+
532535
// Get the component so we can check if it is available
533536
let extension_pkg = manifest
534537
.get_package(&extension.short_name_in_manifest())
@@ -540,8 +543,8 @@ impl<'a> Toolchain<'a> {
540543
});
541544
let extension_target_pkg = extension_pkg
542545
.targets
543-
.get(&toolchain.target)
544-
.expect("extension should have target toolchain");
546+
.get(&extension_target)
547+
.expect("extension should have listed toolchain");
545548

546549
res.push(ComponentStatus {
547550
component: extension.clone(),

tests/cli-v2.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,3 +1083,19 @@ fn remove_target_suggest_best_match() {
10831083
);
10841084
});
10851085
}
1086+
1087+
#[test]
1088+
fn target_list_ignores_unavailable_targets() {
1089+
setup(&|config| {
1090+
expect_ok(config, &["rustup", "default", "nightly"]);
1091+
let target_list = &["rustup", "target", "list"];
1092+
expect_stdout_ok(config, target_list, clitools::CROSS_ARCH1);
1093+
let trip = TargetTriple::new(clitools::CROSS_ARCH1);
1094+
make_component_unavailable(config, "rust-std", &trip);
1095+
expect_ok(
1096+
config,
1097+
&["rustup", "update", "nightly", "--force", "--no-self-update"],
1098+
);
1099+
expect_not_stdout_ok(config, target_list, clitools::CROSS_ARCH1);
1100+
})
1101+
}

0 commit comments

Comments
 (0)