Skip to content

Commit 373c808

Browse files
authored
Merge pull request #2602 from kinnison/fix-2601
Fix 2601
2 parents 456fa8b + dd69540 commit 373c808

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

src/dist/dist.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,12 +730,27 @@ fn try_update_from_dist_<'a>(
730730

731731
let mut all_components: HashSet<Component> = profile_components.into_iter().collect();
732732

733+
let rust_package = m.get_package("rust")?;
734+
let rust_target_package = rust_package.get_target(Some(&toolchain.target.clone()))?;
735+
733736
for component in components.iter().copied() {
734737
let mut component =
735738
Component::new(component.to_string(), Some(toolchain.target.clone()), false);
736739
if let Some(renamed) = m.rename_component(&component) {
737740
component = renamed;
738741
}
742+
// Look up the newly constructed/renamed component and ensure that
743+
// if it's a wildcard component we note such, otherwise we end up
744+
// exacerbating the problem we thought we'd fixed with #2087 and #2115
745+
if let Some(c) = rust_target_package
746+
.components
747+
.iter()
748+
.find(|c| c.short_name_in_manifest() == component.short_name_in_manifest())
749+
{
750+
if c.target.is_none() {
751+
component = component.wildcard();
752+
}
753+
}
739754
all_components.insert(component);
740755
}
741756

src/dist/manifestation.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,10 @@ impl Update {
617617
// It is the case, so we need to create a fresh wildcard
618618
// component using the package name and add it to the final
619619
// component list
620-
self.final_component_list
621-
.push(existing_component.wildcard());
620+
let wildcarded = existing_component.wildcard();
621+
if !self.final_component_list.contains(&wildcarded) {
622+
self.final_component_list.push(wildcarded);
623+
}
622624
} else {
623625
self.missing_components.push(existing_component.clone());
624626
}

tests/cli-v2.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,3 +1517,32 @@ fn install_allow_downgrade() {
15171517
expect_component_executable(config, "rls");
15181518
});
15191519
}
1520+
1521+
#[test]
1522+
fn regression_2601() {
1523+
// We're checking that we don't regress per #2601
1524+
setup(&|config| {
1525+
expect_ok(
1526+
config,
1527+
&[
1528+
"rustup",
1529+
"toolchain",
1530+
"install",
1531+
"--profile",
1532+
"minimal",
1533+
"nightly",
1534+
"--component",
1535+
"rust-src",
1536+
"--no-self-update",
1537+
],
1538+
);
1539+
// The bug exposed in #2601 was that the above would end up installing
1540+
// rust-src-$ARCH which would then have to be healed on the following
1541+
// command, resulting in a reinstallation.
1542+
expect_stderr_ok(
1543+
config,
1544+
&["rustup", "component", "add", "rust-src"],
1545+
"info: component 'rust-src' is up to date",
1546+
);
1547+
});
1548+
}

0 commit comments

Comments
 (0)