Skip to content

Commit 5dabf47

Browse files
committed
fix: Replace the reference to v1 with a method
1 parent 2a350a3 commit 5dabf47

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/cargo/ops/cargo_install.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -336,34 +336,34 @@ fn install_one(
336336
// Update records of replaced binaries.
337337
for &bin in replaced_names.iter() {
338338
if let Some(&Some(ref p)) = duplicates.get(bin) {
339-
if let Some(set) = list.v1.get_mut(p) {
339+
if let Some(set) = list.v1_mut().get_mut(p) {
340340
set.remove(bin);
341341
}
342342
}
343343
// Failsafe to force replacing metadata for git packages
344344
// https://github.com/rust-lang/cargo/issues/4582
345-
if let Some(set) = list.v1.remove(&pkg.package_id()) {
346-
list.v1.insert(pkg.package_id(), set);
345+
if let Some(set) = list.v1_mut().remove(&pkg.package_id()) {
346+
list.v1_mut().insert(pkg.package_id(), set);
347347
}
348-
list.v1
348+
list.v1_mut()
349349
.entry(pkg.package_id())
350350
.or_insert_with(BTreeSet::new)
351351
.insert(bin.to_string());
352352
}
353353

354354
// Remove empty metadata lines.
355355
let pkgs = list
356-
.v1
356+
.v1()
357357
.iter()
358358
.filter_map(|(&p, set)| if set.is_empty() { Some(p) } else { None })
359359
.collect::<Vec<_>>();
360360
for p in pkgs.iter() {
361-
list.v1.remove(p);
361+
list.v1_mut().remove(p);
362362
}
363363

364364
// If installation was successful record newly installed binaries.
365365
if result.is_ok() {
366-
list.v1
366+
list.v1_mut()
367367
.entry(pkg.package_id())
368368
.or_insert_with(BTreeSet::new)
369369
.extend(to_install.iter().map(|s| s.to_string()));
@@ -431,7 +431,7 @@ fn find_duplicates(
431431
let name = format!("{}{}", name, env::consts::EXE_SUFFIX);
432432
if fs::metadata(dst.join(&name)).is_err() {
433433
None
434-
} else if let Some((&p, _)) = prev.v1.iter().find(|&(_, v)| v.contains(&name)) {
434+
} else if let Some((&p, _)) = prev.v1().iter().find(|&(_, v)| v.contains(&name)) {
435435
Some((name, Some(p)))
436436
} else {
437437
Some((name, None))
@@ -477,7 +477,7 @@ pub fn install_list(dst: Option<&str>, config: &Config) -> CargoResult<()> {
477477
let dst = resolve_root(dst, config)?;
478478
let dst = metadata(config, &dst)?;
479479
let list = read_crate_list(&dst)?;
480-
for (k, v) in list.v1.iter() {
480+
for (k, v) in list.v1().iter() {
481481
println!("{}:", k);
482482
for bin in v {
483483
println!(" {}", bin);

src/cargo/ops/cargo_uninstall.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub fn uninstall_one(
7676
) -> CargoResult<()> {
7777
let crate_metadata = metadata(config, root)?;
7878
let metadata = read_crate_list(&crate_metadata)?;
79-
let pkgid = PackageIdSpec::query_str(spec, metadata.v1.keys().cloned())?;
79+
let pkgid = PackageIdSpec::query_str(spec, metadata.v1().keys().cloned())?;
8080
uninstall_pkgid(&crate_metadata, metadata, pkgid, bins, config)
8181
}
8282

@@ -101,10 +101,11 @@ fn uninstall_pkgid(
101101
) -> CargoResult<()> {
102102
let mut to_remove = Vec::new();
103103
{
104-
let mut installed = match metadata.v1.entry(pkgid) {
104+
let mut installed = match metadata.v1_mut().entry(pkgid) {
105105
Entry::Occupied(e) => e,
106106
Entry::Vacant(..) => failure::bail!("package `{}` is not installed", pkgid),
107107
};
108+
108109
let dst = crate_metadata.parent().join("bin");
109110
for bin in installed.get() {
110111
let bin = dst.join(bin);

0 commit comments

Comments
 (0)