Skip to content

Commit

Permalink
Merge pull request #1554 from nrc/fix-renames
Browse files Browse the repository at this point in the history
More tweeks to renames
  • Loading branch information
alexcrichton authored Nov 28, 2018
2 parents a46f3c9 + bf50b3e commit f0a3d9a
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/rustup-cli/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ pub fn rustc_version(toolchain: &Toolchain) -> String {
pub fn list_targets(toolchain: &Toolchain) -> Result<()> {
let mut t = term2::stdout();
for component in toolchain.list_components()? {
if component.component.name_in_manifest() == "rust-std" {
if component.component.short_name_in_manifest() == "rust-std" {
let target = component
.component
.target
Expand Down
2 changes: 1 addition & 1 deletion src/rustup-cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ fn show(cfg: &Cfg) -> Result<()> {
match t.list_components() {
Ok(cs_vec) => cs_vec
.into_iter()
.filter(|c| c.component.name_in_manifest() == "rust-std")
.filter(|c| c.component.short_name_in_manifest() == "rust-std")
.filter(|c| c.installed)
.collect(),
Err(_) => vec![],
Expand Down
10 changes: 9 additions & 1 deletion src/rustup-dist/src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,15 @@ impl Component {
format!("'{}'", pkg)
}
}
pub fn name_in_manifest(&self) -> &String {
pub fn short_name_in_manifest(&self) -> &String {
&self.pkg
}
pub fn name_in_manifest(&self) -> String {
let pkg = self.short_name_in_manifest();
if let Some(ref t) = self.target {
format!("{}-{}", pkg, t)
} else {
format!("{}", pkg)
}
}
}
19 changes: 10 additions & 9 deletions src/rustup-dist/src/manifestation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ impl Manifestation {
// names are not the same as the dist manifest component
// names. Some are just the component name some are the
// component name plus the target triple.
let ref name = component.name(new_manifest);
let ref pkg_name = component.name_in_manifest();
let short_pkg_name = component.short_name_in_manifest();
let short_name = component.short_name(new_manifest);

notify_handler(Notification::InstallingComponent(
Expand All @@ -212,11 +213,11 @@ impl Manifestation {

// If the package doesn't contain the component that the
// manifest says it does then somebody must be playing a joke on us.
if !package.contains(name, Some(&short_name)) {
if !package.contains(pkg_name, Some(&short_pkg_name)) {
return Err(ErrorKind::CorruptComponent(short_name).into());
}

tx = package.install(&self.installation, name, Some(&short_name), tx)?;
tx = package.install(&self.installation, pkg_name, Some(&short_pkg_name), tx)?;
}

// Install new distribution manifest
Expand Down Expand Up @@ -282,14 +283,14 @@ impl Manifestation {
// names are not the same as the dist manifest component
// names. Some are just the component name some are the
// component name plus the target triple.
let ref name = component.name(manifest);
let ref short_name = component.short_name(manifest);
let ref name = component.name_in_manifest();
let ref short_name = component.short_name_in_manifest();
if let Some(c) = self.installation.find(&name)? {
tx = c.uninstall(tx)?;
} else if let Some(c) = self.installation.find(&short_name)? {
tx = c.uninstall(tx)?;
} else {
notify_handler(Notification::MissingInstalledComponent(&name));
notify_handler(Notification::MissingInstalledComponent(&component.short_name(manifest)));
}

Ok(tx)
Expand Down Expand Up @@ -578,7 +579,7 @@ impl Update {
let missing_essential_components = ["rustc", "cargo"]
.iter()
.filter_map(|pkg| {
if self.final_component_list.iter().any(|c| &c.name_in_manifest() == pkg) {
if self.final_component_list.iter().any(|c| &c.short_name_in_manifest() == pkg) {
None
} else {
Some(Component::new(pkg.to_string(), Some(target_triple.clone())))
Expand All @@ -600,7 +601,7 @@ impl Update {
.iter()
.filter(|c| {
use manifest::*;
let pkg: Option<&Package> = new_manifest.get_package(&c.name_in_manifest()).ok();
let pkg: Option<&Package> = new_manifest.get_package(&c.short_name_in_manifest()).ok();
let target_pkg: Option<&TargetedPackage> =
pkg.and_then(|p| p.get_target(c.target.as_ref()).ok());
target_pkg.map(|tp| tp.available()) != Some(true)
Expand All @@ -624,7 +625,7 @@ impl Update {
) -> Result<Vec<(Component, Format, String, String)>> {
let mut components_urls_and_hashes = Vec::new();
for component in &self.components_to_install {
let package = new_manifest.get_package(&component.name_in_manifest())?;
let package = new_manifest.get_package(&component.short_name_in_manifest())?;
let target_package = package.get_target(component.target.as_ref())?;

let bins = target_package.bins.as_ref().expect("components available");
Expand Down
2 changes: 1 addition & 1 deletion src/rustup-dist/tests/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ fn bonus_component(name: &'static str, contents: Arc<Vec<u8>>) -> MockPackage {
installer: MockInstallerBuilder {
components: vec![
MockComponentBuilder {
name: "bonus-x86_64-apple-darwin".to_owned(),
name: format!("{}-x86_64-apple-darwin", name),
files: vec![MockFile::new_arc("bin/bonus", contents)],
},
],
Expand Down
4 changes: 2 additions & 2 deletions src/rustup-dist/tests/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ fn parse_smoke_test() {
assert_eq!(rust_target_pkg.bins.clone().unwrap().hash, "...");

let ref component = rust_target_pkg.components[0];
assert_eq!(component.name_in_manifest(), "rustc");
assert_eq!(component.short_name_in_manifest(), "rustc");
assert_eq!(component.target.as_ref(), Some(&x86_64_unknown_linux_gnu));

let ref component = rust_target_pkg.extensions[0];
assert_eq!(component.name_in_manifest(), "rust-std");
assert_eq!(component.short_name_in_manifest(), "rust-std");
assert_eq!(component.target.as_ref(), Some(&x86_64_unknown_linux_musl));

let docs_pkg = pkg.get_package("rust-docs").unwrap();
Expand Down
8 changes: 6 additions & 2 deletions src/rustup-mock/src/clitools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -764,12 +764,16 @@ fn build_mock_cargo_installer(version: &str, version_hash: &str) -> MockInstalle
fn build_mock_rls_installer(
version: &str,
version_hash: &str,
_preview: bool,
preview: bool,
) -> MockInstallerBuilder {
MockInstallerBuilder {
components: vec![
MockComponentBuilder {
name: "rls".to_string(),
name: if preview {
"rls-preview".to_string()
} else {
"rls".to_string()
},
files: mock_bin("rls", version, version_hash),
},
],
Expand Down
4 changes: 2 additions & 2 deletions src/rustup/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ impl<'a> Toolchain<'a> {
.unwrap_or(false);

// Get the component so we can check if it is available
let component_pkg = manifest.get_package(&component.name_in_manifest()).expect(&format!(
let component_pkg = manifest.get_package(&component.short_name_in_manifest()).expect(&format!(
"manifest should contain component {}",
&component.short_name(&manifest)
));
Expand All @@ -538,7 +538,7 @@ impl<'a> Toolchain<'a> {
.unwrap_or(false);

// Get the component so we can check if it is available
let extension_pkg = manifest.get_package(&extension.name_in_manifest()).expect(&format!(
let extension_pkg = manifest.get_package(&extension.short_name_in_manifest()).expect(&format!(
"manifest should contain extension {}",
&extension.short_name(&manifest)
));
Expand Down

0 comments on commit f0a3d9a

Please sign in to comment.