Skip to content

Commit 62df224

Browse files
authored
Merge pull request #2115 from kinnison/kinnison/mitigate-rust-src-mess
Make target="*" components detectable if ascribed a target.
2 parents c5a06e9 + 0862ba3 commit 62df224

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

src/dist/manifest.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,4 +593,26 @@ impl Component {
593593
String::new()
594594
}
595595
}
596+
597+
pub fn contained_within(&self, components: &[Component]) -> bool {
598+
if components.contains(self) {
599+
// Yes, we're within the component set, move on
600+
true
601+
} else if self.target.is_none() {
602+
// We weren't in the given component set, but we're a package
603+
// which targets "*" and as such older rustups might have
604+
// accidentally made us target specific due to a bug in profiles.
605+
components
606+
.iter()
607+
// As such, if our target is None, it's sufficient to check pkg
608+
.any(|other| other.pkg == self.pkg)
609+
} else {
610+
// As a last ditch effort, we're contained within the component
611+
// set if the name matches and the other component's target
612+
// is None
613+
components
614+
.iter()
615+
.any(|other| other.pkg == self.pkg && other.target.is_none())
616+
}
617+
}
596618
}

src/dist/manifestation.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,19 @@ impl Update {
584584
if component_is_present {
585585
self.final_component_list.push(existing_component.clone());
586586
} else {
587-
self.missing_components.push(existing_component.clone());
587+
// Component not available, check if this is a case of
588+
// where rustup brokenly installed `rust-src` during
589+
// the 1.20.x series
590+
if existing_component.contained_within(&rust_target_package.components)
591+
{
592+
// It is the case, so we need to create a fresh wildcard
593+
// component using the package name and add it to the final
594+
// component list
595+
self.final_component_list
596+
.push(existing_component.wildcard());
597+
} else {
598+
self.missing_components.push(existing_component.clone());
599+
}
588600
}
589601
}
590602
}

src/toolchain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ impl<'a> Toolchain<'a> {
548548
for component in &targ_pkg.components {
549549
let installed = config
550550
.as_ref()
551-
.map(|c| c.components.contains(component))
551+
.map(|c| component.contained_within(&c.components))
552552
.unwrap_or(false);
553553

554554
let component_target = TargetTriple::new(&component.target());

0 commit comments

Comments
 (0)