From 81687e7926800b54aee0c4754f8ec2137c951aea Mon Sep 17 00:00:00 2001 From: bishtpawan Date: Wed, 5 Aug 2020 20:56:56 +0530 Subject: [PATCH] Resolve PR comments --- src/cargo/ops/common_for_install_and_uninstall.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/cargo/ops/common_for_install_and_uninstall.rs b/src/cargo/ops/common_for_install_and_uninstall.rs index 8207e423a2a..9f0c5dd206e 100644 --- a/src/cargo/ops/common_for_install_and_uninstall.rs +++ b/src/cargo/ops/common_for_install_and_uninstall.rs @@ -545,15 +545,13 @@ where Ok(pkg) } None => { - let version: String = dep.version_req().to_string(); - let pkg_id; - if dep.version_req().is_exact() { - pkg_id = PackageId::new(dep.package_name(), &version[1..], source.source_id()); + let is_yanked: bool = if dep.version_req().is_exact() { + let version: String = dep.version_req().to_string(); + PackageId::new(dep.package_name(), &version[1..], source.source_id()) + .map_or(false, |pkg_id| source.is_yanked(pkg_id).unwrap_or(false)) } else { - pkg_id = PackageId::new(dep.package_name(), &version[..], source.source_id()); - } - let is_yanked = - pkg_id.map_or(false, |pkg_id| source.is_yanked(pkg_id).unwrap_or(false)); + false + }; if is_yanked { bail!( "cannot install package `{}`, it has been yanked from {}",