Skip to content

Commit

Permalink
refactor(resolver): Share context across messages
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Dec 11, 2024
1 parent aecffa8 commit f93ebac
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions src/cargo/core/resolver/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,6 @@ pub(super) fn activation_error(
&mut msg,
"candidate versions found which didn't match: {versions}",
);
let mut location_searched_msg = registry.describe_source(dep.source_id());
if location_searched_msg.is_empty() {
location_searched_msg = format!("{}", dep.source_id());
}

let _ = writeln!(&mut msg, "location searched: {}", location_searched_msg);
let _ = write!(
&mut msg,
"required by {}",
describe_path_in_context(resolver_ctx, &parent.package_id()),
);

// If we have a pre-release candidate, then that may be what our user is looking for
if let Some(pre) = candidates.iter().find(|c| c.version().is_prerelease()) {
Expand Down Expand Up @@ -377,19 +366,18 @@ pub(super) fn activation_error(
dep.package_name()
);
}
}

let mut location_searched_msg = registry.describe_source(dep.source_id());
if location_searched_msg.is_empty() {
location_searched_msg = format!("{}", dep.source_id());
}

let _ = writeln!(&mut msg, "location searched: {}", location_searched_msg);
let _ = write!(
&mut msg,
"required by {}",
describe_path_in_context(resolver_ctx, &parent.package_id()),
);
let mut location_searched_msg = registry.describe_source(dep.source_id());
if location_searched_msg.is_empty() {
location_searched_msg = format!("{}", dep.source_id());
}
let _ = writeln!(&mut msg, "location searched: {}", location_searched_msg);
let _ = write!(
&mut msg,
"required by {}",
describe_path_in_context(resolver_ctx, &parent.package_id()),
);

if let Some(gctx) = gctx {
if gctx.offline() {
Expand Down

0 comments on commit f93ebac

Please sign in to comment.