Skip to content

Commit dc0e53b

Browse files
committed
Reworking message to not care about an intial offset
1 parent 671ba3f commit dc0e53b

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

src/cargo/core/resolver/errors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ pub(super) fn activation_error(
285285
.collect();
286286
candidates.sort_by_key(|o| o.0);
287287
let mut msg = format!(
288-
"no matching package named `{}` found\n", dep.package_name());
288+
"no matching package found\nsearched package name: `{}`\n", dep.package_name());
289289
if !candidates.is_empty() {
290290
// If dependency package name is equal to the name of the candidate here
291291
// it may be a prerelease package which hasn't been specified correctly
@@ -309,8 +309,8 @@ pub(super) fn activation_error(
309309
names.push("...");
310310
}
311311
// Vertically align first suggestion with missing crate name
312-
// so the silly typo you probably made jumps out at you.
313-
msg.push_str("perhaps you meant: ");
312+
// so a typo jumps out at you.
313+
msg.push_str("perhaps you meant: ");
314314
msg.push_str(&names.iter().enumerate().fold(
315315
String::default(),
316316
|acc, (i, el)| match i {

tests/testsuite/directory.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,10 @@ fn simple_install_fail() {
191191
error: failed to compile `bar v0.1.0`, intermediate artifacts can be found at `[..]`
192192
193193
Caused by:
194-
no matching package named `baz` found
194+
no matching package found
195+
searched package name: `baz`
196+
perhaps you meant: bar or foo
195197
location searched: registry `https://github.com/rust-lang/crates.io-index`
196-
perhaps you meant: bar or foo
197198
required by package `bar v0.1.0`
198199
",
199200
)

tests/testsuite/path.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -964,9 +964,10 @@ fn invalid_path_dep_in_workspace_with_lockfile() {
964964
.with_status(101)
965965
.with_stderr(
966966
"\
967-
error: no matching package named `bar` found
967+
error: no matching package found
968+
searched package name: `bar`
969+
perhaps you meant: foo
968970
location searched: [..]
969-
perhaps you meant: foo
970971
required by package `foo v0.5.0 ([..])`
971972
",
972973
)

tests/testsuite/registry.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,10 @@ fn wrong_case() {
155155
.with_stderr(
156156
"\
157157
[UPDATING] [..] index
158-
error: no matching package named `Init` found
158+
error: no matching package found
159+
searched package name: `Init`
160+
perhaps you meant: init
159161
location searched: registry [..]
160-
perhaps you meant: init
161162
required by package `foo v0.0.1 ([..])`
162163
",
163164
)
@@ -190,9 +191,10 @@ fn mis_hyphenated() {
190191
.with_stderr(
191192
"\
192193
[UPDATING] [..] index
193-
error: no matching package named `mis_hyphenated` found
194+
error: no matching package found
195+
searched package name: `mis_hyphenated`
196+
perhaps you meant: mis-hyphenated
194197
location searched: registry [..]
195-
perhaps you meant: mis-hyphenated
196198
required by package `foo v0.0.1 ([..])`
197199
",
198200
)
@@ -1439,9 +1441,9 @@ fn use_semver_package_incorrectly() {
14391441
.with_stderr(
14401442
"\
14411443
error: no matching package named `a` found
1442-
location searched: [..]
14431444
prerelease package needs to be specified explicitly
14441445
a = { version = \"0.1.1-alpha.0\" }
1446+
location searched: [..]
14451447
required by package `b v0.1.0 ([..])`
14461448
",
14471449
)

0 commit comments

Comments
 (0)