From dc0e53b7c1e472f056ad8e4f369c9188f342ded8 Mon Sep 17 00:00:00 2001 From: gilescope Date: Sat, 10 Jul 2021 15:07:29 +0100 Subject: [PATCH] Reworking message to not care about an intial offset --- src/cargo/core/resolver/errors.rs | 6 +++--- tests/testsuite/directory.rs | 5 +++-- tests/testsuite/path.rs | 5 +++-- tests/testsuite/registry.rs | 12 +++++++----- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/cargo/core/resolver/errors.rs b/src/cargo/core/resolver/errors.rs index e163301fe..0852608d1 100644 --- a/src/cargo/core/resolver/errors.rs +++ b/src/cargo/core/resolver/errors.rs @@ -285,7 +285,7 @@ pub(super) fn activation_error( .collect(); candidates.sort_by_key(|o| o.0); let mut msg = format!( - "no matching package named `{}` found\n", dep.package_name()); + "no matching package found\nsearched package name: `{}`\n", dep.package_name()); if !candidates.is_empty() { // If dependency package name is equal to the name of the candidate here // it may be a prerelease package which hasn't been specified correctly @@ -309,8 +309,8 @@ pub(super) fn activation_error( names.push("..."); } // Vertically align first suggestion with missing crate name - // so the silly typo you probably made jumps out at you. - msg.push_str("perhaps you meant: "); + // so a typo jumps out at you. + msg.push_str("perhaps you meant: "); msg.push_str(&names.iter().enumerate().fold( String::default(), |acc, (i, el)| match i { diff --git a/tests/testsuite/directory.rs b/tests/testsuite/directory.rs index 8f35a8759..8ec514e86 100644 --- a/tests/testsuite/directory.rs +++ b/tests/testsuite/directory.rs @@ -191,9 +191,10 @@ fn simple_install_fail() { error: failed to compile `bar v0.1.0`, intermediate artifacts can be found at `[..]` Caused by: - no matching package named `baz` found + no matching package found + searched package name: `baz` + perhaps you meant: bar or foo location searched: registry `https://github.com/rust-lang/crates.io-index` - perhaps you meant: bar or foo required by package `bar v0.1.0` ", ) diff --git a/tests/testsuite/path.rs b/tests/testsuite/path.rs index eac28090a..3043a85e0 100644 --- a/tests/testsuite/path.rs +++ b/tests/testsuite/path.rs @@ -964,9 +964,10 @@ fn invalid_path_dep_in_workspace_with_lockfile() { .with_status(101) .with_stderr( "\ -error: no matching package named `bar` found +error: no matching package found +searched package name: `bar` +perhaps you meant: foo location searched: [..] -perhaps you meant: foo required by package `foo v0.5.0 ([..])` ", ) diff --git a/tests/testsuite/registry.rs b/tests/testsuite/registry.rs index 854ad1af0..a91f8417a 100644 --- a/tests/testsuite/registry.rs +++ b/tests/testsuite/registry.rs @@ -155,9 +155,10 @@ fn wrong_case() { .with_stderr( "\ [UPDATING] [..] index -error: no matching package named `Init` found +error: no matching package found +searched package name: `Init` +perhaps you meant: init location searched: registry [..] -perhaps you meant: init required by package `foo v0.0.1 ([..])` ", ) @@ -190,9 +191,10 @@ fn mis_hyphenated() { .with_stderr( "\ [UPDATING] [..] index -error: no matching package named `mis_hyphenated` found +error: no matching package found +searched package name: `mis_hyphenated` +perhaps you meant: mis-hyphenated location searched: registry [..] -perhaps you meant: mis-hyphenated required by package `foo v0.0.1 ([..])` ", ) @@ -1439,9 +1441,9 @@ fn use_semver_package_incorrectly() { .with_stderr( "\ error: no matching package named `a` found -location searched: [..] prerelease package needs to be specified explicitly a = { version = \"0.1.1-alpha.0\" } +location searched: [..] required by package `b v0.1.0 ([..])` ", )