Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make target="*" components detectable if ascribed a target. #2115

Merged
merged 1 commit into from
Nov 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/dist/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,4 +593,26 @@ impl Component {
String::new()
}
}

pub fn contained_within(&self, components: &[Component]) -> bool {
if components.contains(self) {
// Yes, we're within the component set, move on
true
} else if self.target.is_none() {
// We weren't in the given component set, but we're a package
// which targets "*" and as such older rustups might have
// accidentally made us target specific due to a bug in profiles.
components
.iter()
// As such, if our target is None, it's sufficient to check pkg
.any(|other| other.pkg == self.pkg)
} else {
// As a last ditch effort, we're contained within the component
// set if the name matches and the other component's target
// is None
components
.iter()
.any(|other| other.pkg == self.pkg && other.target.is_none())
}
}
}
14 changes: 13 additions & 1 deletion src/dist/manifestation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,19 @@ impl Update {
if component_is_present {
self.final_component_list.push(existing_component.clone());
} else {
self.missing_components.push(existing_component.clone());
// Component not available, check if this is a case of
// where rustup brokenly installed `rust-src` during
// the 1.20.x series
if existing_component.contained_within(&rust_target_package.components)
{
// It is the case, so we need to create a fresh wildcard
// component using the package name and add it to the final
// component list
self.final_component_list
.push(existing_component.wildcard());
} else {
self.missing_components.push(existing_component.clone());
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ impl<'a> Toolchain<'a> {
for component in &targ_pkg.components {
let installed = config
.as_ref()
.map(|c| c.components.contains(component))
.map(|c| component.contained_within(&c.components))
.unwrap_or(false);

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