Skip to content

Commit f7353d7

Browse files
committed
Yield references from Manifest::short_name()
1 parent 438ba95 commit f7353d7

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

src/dist/manifest.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl Manifest {
5656
if let Some(t) = &component.target {
5757
format!("{pkg}-{t}")
5858
} else {
59-
pkg
59+
pkg.to_owned()
6060
}
6161
}
6262

@@ -69,11 +69,11 @@ impl Manifest {
6969
}
7070
}
7171

72-
pub(crate) fn short_name(&self, component: &Component) -> String {
72+
pub(crate) fn short_name<'a>(&'a self, component: &'a Component) -> &'a str {
7373
if let Some(from) = self.reverse_renames.get(&component.pkg) {
74-
from.to_owned()
74+
from
7575
} else {
76-
component.pkg.clone()
76+
&component.pkg
7777
}
7878
}
7979
}
@@ -380,12 +380,12 @@ impl Manifest {
380380

381381
fn validate_targeted_package(&self, tpkg: &TargetedPackage) -> Result<()> {
382382
for c in tpkg.components.iter() {
383-
let cpkg = self
384-
.get_package(&c.pkg)
385-
.with_context(|| RustupError::MissingPackageForComponent(self.short_name(c)))?;
386-
let _ctpkg = cpkg
387-
.get_target(c.target.as_ref())
388-
.with_context(|| RustupError::MissingPackageForComponent(self.short_name(c)))?;
383+
let cpkg = self.get_package(&c.pkg).with_context(|| {
384+
RustupError::MissingPackageForComponent(self.short_name(c).to_owned())
385+
})?;
386+
let _ctpkg = cpkg.get_target(c.target.as_ref()).with_context(|| {
387+
RustupError::MissingPackageForComponent(self.short_name(c).to_owned())
388+
})?;
389389
}
390390
Ok(())
391391
}

src/dist/manifestation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ impl<'a> ComponentBinary<'a> {
634634
Ok(None) => return None,
635635
Err(e) => return Some(Err(e)),
636636
},
637-
status: download_cfg.status_for(manifest.short_name(&component)),
637+
status: download_cfg.status_for(manifest.short_name(&component).to_owned()),
638638
component,
639639
manifest,
640640
download_cfg,
@@ -699,7 +699,7 @@ impl<'a> ComponentBinary<'a> {
699699
// If the package doesn't contain the component that the
700700
// manifest says it does then somebody must be playing a joke on us.
701701
if !package.contains(&pkg_name, Some(short_pkg_name)) {
702-
return Err(RustupError::CorruptComponent(short_name).into());
702+
return Err(RustupError::CorruptComponent(short_name.to_owned()).into());
703703
}
704704

705705
let tx = package.install(

src/dist/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ impl<'cfg, 'a> DistOptions<'cfg, 'a> {
10481048
.iter()
10491049
.map(|component| {
10501050
match component.target.as_ref() == Some(&toolchain.target) {
1051-
true => manifest.short_name(component),
1051+
true => manifest.short_name(component).to_owned(),
10521052
false => manifest.name(component),
10531053
}
10541054
})

src/toolchain/distributable.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ impl<'a> DistributableToolchain<'a> {
170170
let wanted_components = components.iter().all(|name| {
171171
installed_components.iter().any(|status| {
172172
let cname = manifest.short_name(&status.component);
173-
let cname = cname.as_str();
174173
let cnameim = status.component.short_name_in_manifest();
175174
let cnameim = cnameim.as_str();
176175
(cname == *name || cnameim == *name) && status.installed
@@ -284,7 +283,9 @@ impl<'a> DistributableToolchain<'a> {
284283
.expect("There should be always at least one component");
285284

286285
let mut closest_distance = short_name_distance;
287-
let mut closest_match = manifest.short_name(&short_name_distance.1.component);
286+
let mut closest_match = manifest
287+
.short_name(&short_name_distance.1.component)
288+
.to_owned();
288289

289290
// Find closer suggestion
290291
if short_name_distance.0 > long_name_distance.0 {

0 commit comments

Comments
 (0)