mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Don't include a special-case error for a locked patch matching 0 entries.
This commit is contained in:
parent
2c0cd9741d
commit
6fd11a7768
@ -772,9 +772,9 @@ fn summary_for_patch(
|
|||||||
}
|
}
|
||||||
assert!(summaries.is_empty());
|
assert!(summaries.is_empty());
|
||||||
// No summaries found, try to help the user figure out what is wrong.
|
// No summaries found, try to help the user figure out what is wrong.
|
||||||
if let Some((locked_patch, locked_id)) = locked {
|
if let Some((_locked_patch, locked_id)) = locked {
|
||||||
// Since the locked patch did not match anything, try the unlocked one.
|
// Since the locked patch did not match anything, try the unlocked one.
|
||||||
let mut orig_matches = source.query_vec(orig_patch).unwrap_or_else(|e| {
|
let orig_matches = source.query_vec(orig_patch).unwrap_or_else(|e| {
|
||||||
log::warn!(
|
log::warn!(
|
||||||
"could not determine unlocked summaries for dep {:?}: {:?}",
|
"could not determine unlocked summaries for dep {:?}: {:?}",
|
||||||
orig_patch,
|
orig_patch,
|
||||||
@ -782,68 +782,49 @@ fn summary_for_patch(
|
|||||||
);
|
);
|
||||||
Vec::new()
|
Vec::new()
|
||||||
});
|
});
|
||||||
if orig_matches.is_empty() {
|
let (summary, _) = summary_for_patch(orig_patch, &None, orig_matches, source)?;
|
||||||
// This should be relatively unusual. For example, a patch of
|
|
||||||
// {version="0.1.2", ...} and the patch location no longer contains a
|
|
||||||
// version that matches "0.1.2". It is unusual to explicitly write a
|
|
||||||
// version in the patch.
|
|
||||||
anyhow::bail!(
|
|
||||||
"The patch is locked to {} in Cargo.lock, but the version in the \
|
|
||||||
patch location does not match any packages in the patch location.\n\
|
|
||||||
Make sure the patch points to the correct version.",
|
|
||||||
locked_patch.version_req(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
let summary = best_summary(&mut orig_matches);
|
|
||||||
debug!(
|
|
||||||
"locked patch no longer matches, but unlocked version should work. \
|
|
||||||
locked={:?} unlocked={:?} summary={:?}",
|
|
||||||
locked, orig_patch, summary
|
|
||||||
);
|
|
||||||
// The unlocked version found a match. This returns a value to
|
// The unlocked version found a match. This returns a value to
|
||||||
// indicate that this entry should be unlocked.
|
// indicate that this entry should be unlocked.
|
||||||
return Ok((summary, Some(*locked_id)));
|
return Ok((summary, Some(*locked_id)));
|
||||||
} else {
|
}
|
||||||
// Try checking if there are *any* packages that match this by name.
|
// Try checking if there are *any* packages that match this by name.
|
||||||
let name_only_dep =
|
let name_only_dep = Dependency::new_override(orig_patch.package_name(), orig_patch.source_id());
|
||||||
Dependency::new_override(orig_patch.package_name(), orig_patch.source_id());
|
let name_summaries = source.query_vec(&name_only_dep).unwrap_or_else(|e| {
|
||||||
let name_summaries = source.query_vec(&name_only_dep).unwrap_or_else(|e| {
|
log::warn!(
|
||||||
log::warn!(
|
"failed to do name-only summary query for {:?}: {:?}",
|
||||||
"failed to do name-only summary query for {:?}: {:?}",
|
name_only_dep,
|
||||||
name_only_dep,
|
e
|
||||||
e
|
);
|
||||||
);
|
Vec::new()
|
||||||
Vec::new()
|
});
|
||||||
});
|
let mut vers = name_summaries
|
||||||
let mut vers = name_summaries
|
.iter()
|
||||||
.iter()
|
.map(|summary| summary.version())
|
||||||
.map(|summary| summary.version())
|
.collect::<Vec<_>>();
|
||||||
.collect::<Vec<_>>();
|
let found = match vers.len() {
|
||||||
let found = match vers.len() {
|
0 => format!(""),
|
||||||
0 => format!(""),
|
1 => format!("version `{}`", vers[0]),
|
||||||
1 => format!("version `{}`", vers[0]),
|
_ => {
|
||||||
_ => {
|
vers.sort();
|
||||||
vers.sort();
|
let strs: Vec<_> = vers.into_iter().map(|v| v.to_string()).collect();
|
||||||
let strs: Vec<_> = vers.into_iter().map(|v| v.to_string()).collect();
|
format!("versions `{}`", strs.join(", "))
|
||||||
format!("versions `{}`", strs.join(", "))
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if found.is_empty() {
|
|
||||||
anyhow::bail!(
|
|
||||||
"The patch location does not appear to contain any packages \
|
|
||||||
matching the name `{}`.",
|
|
||||||
orig_patch.package_name()
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
anyhow::bail!(
|
|
||||||
"The patch location contains a `{}` package with {}, but the patch \
|
|
||||||
definition requires `{}`.\n\
|
|
||||||
Check that the version in the patch location is what you expect, \
|
|
||||||
and update the patch definition to match.",
|
|
||||||
orig_patch.package_name(),
|
|
||||||
found,
|
|
||||||
orig_patch.version_req()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
if found.is_empty() {
|
||||||
|
anyhow::bail!(
|
||||||
|
"The patch location does not appear to contain any packages \
|
||||||
|
matching the name `{}`.",
|
||||||
|
orig_patch.package_name()
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
anyhow::bail!(
|
||||||
|
"The patch location contains a `{}` package with {}, but the patch \
|
||||||
|
definition requires `{}`.\n\
|
||||||
|
Check that the version in the patch location is what you expect, \
|
||||||
|
and update the patch definition to match.",
|
||||||
|
orig_patch.package_name(),
|
||||||
|
found,
|
||||||
|
orig_patch.version_req()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1763,8 +1763,8 @@ Caused by:
|
|||||||
patch for `bar` in `https://github.com/rust-lang/crates.io-index` did not resolve to any crates
|
patch for `bar` in `https://github.com/rust-lang/crates.io-index` did not resolve to any crates
|
||||||
|
|
||||||
Caused by:
|
Caused by:
|
||||||
The patch is locked to = 0.1.1 in Cargo.lock, but the version in the patch location does not match any packages in the patch location.
|
The patch location contains a `bar` package with version `0.1.0`, but the patch definition requires `^0.1.1`.
|
||||||
Make sure the patch points to the correct version.
|
Check that the version in the patch location is what you expect, and update the patch definition to match.
|
||||||
",
|
",
|
||||||
)
|
)
|
||||||
.run();
|
.run();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user