Skip to content

Commit ecc6ec6

Browse files
committed
refactor (patch): remove variable with confusing name
1 parent 5bd1543 commit ecc6ec6

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

src/cargo/core/registry.rs

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,12 @@ impl<'gctx> PackageRegistry<'gctx> {
477477
let name = summary.package_id().name();
478478
let version = summary.package_id().version();
479479
if !name_and_version.insert((name, version)) {
480-
let duplicate_locations: Vec<_> = patch_deps.iter().filter(|&p| p.0.dep.package_name() == name).map(|p| p.0.loc.to_string()).unique().collect();
480+
let duplicate_locations: Vec<_> = patch_deps
481+
.iter()
482+
.filter(|&p| p.0.dep.package_name() == name)
483+
.map(|p| p.0.loc.to_string())
484+
.unique()
485+
.collect();
481486
return Err(anyhow::anyhow!(
482487
"Cannot have two `[patch]` entries which both resolve to `{} v{}`.\n\
483488
Check patch definitions for `{}` in `{}`",
@@ -943,7 +948,6 @@ fn summary_for_patch(
943948
mut summaries: Vec<Summary>,
944949
source: &mut dyn Source,
945950
) -> Poll<CargoResult<(Summary, Option<PackageId>)>> {
946-
let orig_patch = &original_patch.dep;
947951
if summaries.len() == 1 {
948952
return Poll::Ready(Ok((summaries.pop().unwrap(), None)));
949953
}
@@ -964,8 +968,8 @@ fn summary_for_patch(
964968
Update the patch definition in `{}` to select only one package.\n\
965969
For example, add an `=` version requirement to the patch definition, \
966970
such as `version = \"={}\"`.",
967-
orig_patch.package_name(),
968-
orig_patch.source_id(),
971+
&original_patch.dep.package_name(),
972+
&original_patch.dep.source_id(),
969973
versions.join(", "),
970974
original_patch.loc,
971975
versions.last().unwrap()
@@ -975,23 +979,31 @@ fn summary_for_patch(
975979
// No summaries found, try to help the user figure out what is wrong.
976980
if let Some(locked) = locked {
977981
// Since the locked patch did not match anything, try the unlocked one.
978-
let orig_matches =
979-
ready!(source.query_vec(orig_patch, QueryKind::Exact)).unwrap_or_else(|e| {
982+
let orig_matches = ready!(source.query_vec(&original_patch.dep, QueryKind::Exact))
983+
.unwrap_or_else(|e| {
980984
tracing::warn!(
981985
"could not determine unlocked summaries for dep {:?}: {:?}",
982-
orig_patch,
986+
&original_patch.dep,
983987
e
984988
);
985989
Vec::new()
986990
});
987991

988992
let orig_matches = orig_matches.into_iter().map(|s| s.into_summary()).collect();
989993

990-
let summary = ready!(summary_for_patch(original_patch, &None, orig_matches, source))?;
994+
let summary = ready!(summary_for_patch(
995+
original_patch,
996+
&None,
997+
orig_matches,
998+
source
999+
))?;
9911000
return Poll::Ready(Ok((summary.0, Some(locked.package_id))));
9921001
}
9931002
// Try checking if there are *any* packages that match this by name.
994-
let name_only_dep = Dependency::new_override(orig_patch.package_name(), orig_patch.source_id());
1003+
let name_only_dep = Dependency::new_override(
1004+
original_patch.dep.package_name(),
1005+
original_patch.dep.source_id(),
1006+
);
9951007

9961008
let name_summaries =
9971009
ready!(source.query_vec(&name_only_dep, QueryKind::Exact)).unwrap_or_else(|e| {
@@ -1020,8 +1032,8 @@ fn summary_for_patch(
10201032
"The patch location `{}` does not appear to contain any packages \
10211033
matching the name `{}`.\n\
10221034
Check the patch definition in `{}`.",
1023-
orig_patch.source_id(),
1024-
orig_patch.package_name(),
1035+
&original_patch.dep.source_id(),
1036+
&original_patch.dep.package_name(),
10251037
original_patch.loc
10261038
)
10271039
} else {
@@ -1030,11 +1042,11 @@ fn summary_for_patch(
10301042
definition in `{}` requires `{}`.\n\
10311043
Check that the version in the patch location is what you expect, \
10321044
and update the patch definition to match.",
1033-
orig_patch.source_id(),
1034-
orig_patch.package_name(),
1045+
&original_patch.dep.source_id(),
1046+
&original_patch.dep.package_name(),
10351047
found,
10361048
original_patch.loc,
1037-
orig_patch.version_req()
1049+
&original_patch.dep.version_req()
10381050
)
10391051
}))
10401052
}

0 commit comments

Comments
 (0)