Skip to content

Commit bf50b3e

Browse files
committed
More tweeks to renames
1 parent a46f3c9 commit bf50b3e

File tree

8 files changed

+32
-19
lines changed

8 files changed

+32
-19
lines changed

src/rustup-cli/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ pub fn rustc_version(toolchain: &Toolchain) -> String {
284284
pub fn list_targets(toolchain: &Toolchain) -> Result<()> {
285285
let mut t = term2::stdout();
286286
for component in toolchain.list_components()? {
287-
if component.component.name_in_manifest() == "rust-std" {
287+
if component.component.short_name_in_manifest() == "rust-std" {
288288
let target = component
289289
.component
290290
.target

src/rustup-cli/rustup_mode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ fn show(cfg: &Cfg) -> Result<()> {
650650
match t.list_components() {
651651
Ok(cs_vec) => cs_vec
652652
.into_iter()
653-
.filter(|c| c.component.name_in_manifest() == "rust-std")
653+
.filter(|c| c.component.short_name_in_manifest() == "rust-std")
654654
.filter(|c| c.installed)
655655
.collect(),
656656
Err(_) => vec![],

src/rustup-dist/src/manifest.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,15 @@ impl Component {
432432
format!("'{}'", pkg)
433433
}
434434
}
435-
pub fn name_in_manifest(&self) -> &String {
435+
pub fn short_name_in_manifest(&self) -> &String {
436436
&self.pkg
437437
}
438+
pub fn name_in_manifest(&self) -> String {
439+
let pkg = self.short_name_in_manifest();
440+
if let Some(ref t) = self.target {
441+
format!("{}-{}", pkg, t)
442+
} else {
443+
format!("{}", pkg)
444+
}
445+
}
438446
}

src/rustup-dist/src/manifestation.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ impl Manifestation {
188188
// names are not the same as the dist manifest component
189189
// names. Some are just the component name some are the
190190
// component name plus the target triple.
191-
let ref name = component.name(new_manifest);
191+
let ref pkg_name = component.name_in_manifest();
192+
let short_pkg_name = component.short_name_in_manifest();
192193
let short_name = component.short_name(new_manifest);
193194

194195
notify_handler(Notification::InstallingComponent(
@@ -212,11 +213,11 @@ impl Manifestation {
212213

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

219-
tx = package.install(&self.installation, name, Some(&short_name), tx)?;
220+
tx = package.install(&self.installation, pkg_name, Some(&short_pkg_name), tx)?;
220221
}
221222

222223
// Install new distribution manifest
@@ -282,14 +283,14 @@ impl Manifestation {
282283
// names are not the same as the dist manifest component
283284
// names. Some are just the component name some are the
284285
// component name plus the target triple.
285-
let ref name = component.name(manifest);
286-
let ref short_name = component.short_name(manifest);
286+
let ref name = component.name_in_manifest();
287+
let ref short_name = component.short_name_in_manifest();
287288
if let Some(c) = self.installation.find(&name)? {
288289
tx = c.uninstall(tx)?;
289290
} else if let Some(c) = self.installation.find(&short_name)? {
290291
tx = c.uninstall(tx)?;
291292
} else {
292-
notify_handler(Notification::MissingInstalledComponent(&name));
293+
notify_handler(Notification::MissingInstalledComponent(&component.short_name(manifest)));
293294
}
294295

295296
Ok(tx)
@@ -578,7 +579,7 @@ impl Update {
578579
let missing_essential_components = ["rustc", "cargo"]
579580
.iter()
580581
.filter_map(|pkg| {
581-
if self.final_component_list.iter().any(|c| &c.name_in_manifest() == pkg) {
582+
if self.final_component_list.iter().any(|c| &c.short_name_in_manifest() == pkg) {
582583
None
583584
} else {
584585
Some(Component::new(pkg.to_string(), Some(target_triple.clone())))
@@ -600,7 +601,7 @@ impl Update {
600601
.iter()
601602
.filter(|c| {
602603
use manifest::*;
603-
let pkg: Option<&Package> = new_manifest.get_package(&c.name_in_manifest()).ok();
604+
let pkg: Option<&Package> = new_manifest.get_package(&c.short_name_in_manifest()).ok();
604605
let target_pkg: Option<&TargetedPackage> =
605606
pkg.and_then(|p| p.get_target(c.target.as_ref()).ok());
606607
target_pkg.map(|tp| tp.available()) != Some(true)
@@ -624,7 +625,7 @@ impl Update {
624625
) -> Result<Vec<(Component, Format, String, String)>> {
625626
let mut components_urls_and_hashes = Vec::new();
626627
for component in &self.components_to_install {
627-
let package = new_manifest.get_package(&component.name_in_manifest())?;
628+
let package = new_manifest.get_package(&component.short_name_in_manifest())?;
628629
let target_package = package.get_target(component.target.as_ref())?;
629630

630631
let bins = target_package.bins.as_ref().expect("components available");

src/rustup-dist/tests/dist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ fn bonus_component(name: &'static str, contents: Arc<Vec<u8>>) -> MockPackage {
233233
installer: MockInstallerBuilder {
234234
components: vec![
235235
MockComponentBuilder {
236-
name: "bonus-x86_64-apple-darwin".to_owned(),
236+
name: format!("{}-x86_64-apple-darwin", name),
237237
files: vec![MockFile::new_arc("bin/bonus", contents)],
238238
},
239239
],

src/rustup-dist/tests/manifest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ fn parse_smoke_test() {
3333
assert_eq!(rust_target_pkg.bins.clone().unwrap().hash, "...");
3434

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

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

4343
let docs_pkg = pkg.get_package("rust-docs").unwrap();

src/rustup-mock/src/clitools.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -764,12 +764,16 @@ fn build_mock_cargo_installer(version: &str, version_hash: &str) -> MockInstalle
764764
fn build_mock_rls_installer(
765765
version: &str,
766766
version_hash: &str,
767-
_preview: bool,
767+
preview: bool,
768768
) -> MockInstallerBuilder {
769769
MockInstallerBuilder {
770770
components: vec![
771771
MockComponentBuilder {
772-
name: "rls".to_string(),
772+
name: if preview {
773+
"rls-preview".to_string()
774+
} else {
775+
"rls".to_string()
776+
},
773777
files: mock_bin("rls", version, version_hash),
774778
},
775779
],

src/rustup/toolchain.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ impl<'a> Toolchain<'a> {
513513
.unwrap_or(false);
514514

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

540540
// Get the component so we can check if it is available
541-
let extension_pkg = manifest.get_package(&extension.name_in_manifest()).expect(&format!(
541+
let extension_pkg = manifest.get_package(&extension.short_name_in_manifest()).expect(&format!(
542542
"manifest should contain extension {}",
543543
&extension.short_name(&manifest)
544544
));

0 commit comments

Comments
 (0)