Skip to content

Commit e94199c

Browse files
committed
Only put it on a new line if there's candidates to compare against.
1 parent dc0e53b commit e94199c

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/cargo/core/resolver/errors.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,15 @@ pub(super) fn activation_error(
284284
.filter(|&(d, _)| d < 4)
285285
.collect();
286286
candidates.sort_by_key(|o| o.0);
287-
let mut msg = format!(
288-
"no matching package found\nsearched package name: `{}`\n", dep.package_name());
289-
if !candidates.is_empty() {
287+
let mut msg: String;
288+
if candidates.is_empty() {
289+
msg = format!("no matching package named `{}` found\n", dep.package_name());
290+
} else {
291+
msg = format!(
292+
"no matching package found\nsearched package name: `{}`\n",
293+
dep.package_name()
294+
);
295+
290296
// If dependency package name is equal to the name of the candidate here
291297
// it may be a prerelease package which hasn't been specified correctly
292298
if dep.package_name() == candidates[0].1.name()

tests/testsuite/registry.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,8 @@ fn use_semver_package_incorrectly() {
14401440
.with_status(101)
14411441
.with_stderr(
14421442
"\
1443-
error: no matching package named `a` found
1443+
error: no matching package found
1444+
searched package name: `a`
14441445
prerelease package needs to be specified explicitly
14451446
a = { version = \"0.1.1-alpha.0\" }
14461447
location searched: [..]

0 commit comments

Comments
 (0)