From 7dc7b1bc99d5843092b52761e8cf8d2af17c3821 Mon Sep 17 00:00:00 2001 From: LuuuX Date: Wed, 21 Feb 2024 13:12:50 +0800 Subject: [PATCH 1/3] Add two tests to make sure fixup --- .../in/.cargo/config.toml | 5 +++ .../in/Cargo.toml | 5 +++ .../in/src/lib.rs | 0 .../in/vendor/aa/.cargo-checksum.json | 1 + .../in/vendor/aa/Cargo.toml | 5 +++ .../in/vendor/aa/src/lib.rs | 0 .../mod.rs | 35 +++++++++++++++++++ .../out/Cargo.toml | 8 +++++ .../stderr.log | 11 ++++++ .../stdout.log | 0 .../in/.cargo/config.toml | 5 +++ .../in/Cargo.toml | 5 +++ .../in/src/lib.rs | 0 .../in/vendor/aa/.cargo-checksum.json | 1 + .../in/vendor/aa/Cargo.toml | 5 +++ .../in/vendor/aa/src/lib.rs | 0 .../mod.rs | 23 ++++++++++++ .../out/Cargo.toml | 8 +++++ .../stderr.log | 2 ++ .../stdout.log | 0 tests/testsuite/cargo_add/mod.rs | 2 ++ 21 files changed, 121 insertions(+) create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/.cargo/config.toml create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/Cargo.toml create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/src/lib.rs create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/vendor/aa/.cargo-checksum.json create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/vendor/aa/Cargo.toml create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/vendor/aa/src/lib.rs create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/mod.rs create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/out/Cargo.toml create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/stderr.log create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/stdout.log create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/.cargo/config.toml create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/Cargo.toml create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/src/lib.rs create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/vendor/aa/.cargo-checksum.json create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/vendor/aa/Cargo.toml create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/vendor/aa/src/lib.rs create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/mod.rs create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/out/Cargo.toml create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/stderr.log create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/stdout.log diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/.cargo/config.toml b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/.cargo/config.toml new file mode 100644 index 000000000..77765fb2c --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/.cargo/config.toml @@ -0,0 +1,5 @@ +[source.crates-io] +replace-with = "vendored-sources" + +[source.vendored-sources] +directory = "./vendor" \ No newline at end of file diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/Cargo.toml b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/Cargo.toml new file mode 100644 index 000000000..cc2e9e100 --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/Cargo.toml @@ -0,0 +1,5 @@ +[workspace] + +[package] +name = "cargo-list-test-fixture" +version = "0.0.0" \ No newline at end of file diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/src/lib.rs b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/src/lib.rs new file mode 100644 index 000000000..e69de29bb diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/vendor/aa/.cargo-checksum.json b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/vendor/aa/.cargo-checksum.json new file mode 100644 index 000000000..6b05e7794 --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/vendor/aa/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{}} \ No newline at end of file diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/vendor/aa/Cargo.toml b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/vendor/aa/Cargo.toml new file mode 100644 index 000000000..4ccb59396 --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/vendor/aa/Cargo.toml @@ -0,0 +1,5 @@ +[workspace] + +[package] +name = "aa" +version = "0.0.0" \ No newline at end of file diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/vendor/aa/src/lib.rs b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/vendor/aa/src/lib.rs new file mode 100644 index 000000000..e69de29bb diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/mod.rs b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/mod.rs new file mode 100644 index 000000000..e4efa7b61 --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/mod.rs @@ -0,0 +1,35 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::current_dir; +use cargo_test_support::file; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +#[cargo_test] +fn case() { + cargo_test_support::registry::alt_init(); + cargo_test_support::registry::Package::new("linked-hash-map", "0.5.4") + .feature("clippy", &[]) + .feature("heapsize", &[]) + .feature("heapsize_impl", &[]) + .feature("nightly", &[]) + .feature("serde", &[]) + .feature("serde_impl", &[]) + .feature("serde_test", &[]) + .alternative(true) + .publish(); + + let project = Project::from_template(current_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("add") + .arg_line("linked_hash_map --registry alternative") + .current_dir(cwd) + .assert() + .success() + .stdout_matches(file!["stdout.log"]) + .stderr_matches(file!["stderr.log"]); + + assert_ui().subset_matches(current_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/out/Cargo.toml b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/out/Cargo.toml new file mode 100644 index 000000000..1fe8332c1 --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/out/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] + +[package] +name = "cargo-list-test-fixture" +version = "0.0.0" + +[dependencies] +linked-hash-map = { version = "0.5.4", registry = "alternative" } diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/stderr.log b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/stderr.log new file mode 100644 index 000000000..004713758 --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/stderr.log @@ -0,0 +1,11 @@ + Updating `alternative` index +warning: translating `linked_hash_map` to `linked-hash-map` + Adding linked-hash-map v0.5.4 to dependencies + Features: + - clippy + - heapsize + - heapsize_impl + - nightly + - serde + - serde_impl + - serde_test diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/stdout.log b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/stdout.log new file mode 100644 index 000000000..e69de29bb diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/.cargo/config.toml b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/.cargo/config.toml new file mode 100644 index 000000000..77765fb2c --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/.cargo/config.toml @@ -0,0 +1,5 @@ +[source.crates-io] +replace-with = "vendored-sources" + +[source.vendored-sources] +directory = "./vendor" \ No newline at end of file diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/Cargo.toml b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/Cargo.toml new file mode 100644 index 000000000..cc2e9e100 --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/Cargo.toml @@ -0,0 +1,5 @@ +[workspace] + +[package] +name = "cargo-list-test-fixture" +version = "0.0.0" \ No newline at end of file diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/src/lib.rs b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/src/lib.rs new file mode 100644 index 000000000..e69de29bb diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/vendor/aa/.cargo-checksum.json b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/vendor/aa/.cargo-checksum.json new file mode 100644 index 000000000..6b05e7794 --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/vendor/aa/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{}} \ No newline at end of file diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/vendor/aa/Cargo.toml b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/vendor/aa/Cargo.toml new file mode 100644 index 000000000..4ccb59396 --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/vendor/aa/Cargo.toml @@ -0,0 +1,5 @@ +[workspace] + +[package] +name = "aa" +version = "0.0.0" \ No newline at end of file diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/vendor/aa/src/lib.rs b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/vendor/aa/src/lib.rs new file mode 100644 index 000000000..e69de29bb diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/mod.rs b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/mod.rs new file mode 100644 index 000000000..ba41a5896 --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/mod.rs @@ -0,0 +1,23 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::current_dir; +use cargo_test_support::file; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +#[cargo_test] +fn case() { + let project = Project::from_template(current_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("add") + .arg_line("cbindgen") + .current_dir(cwd) + .assert() + .success() + .stdout_matches(file!["stdout.log"]) + .stderr_matches(file!["stderr.log"]); + + assert_ui().subset_matches(current_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/out/Cargo.toml b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/out/Cargo.toml new file mode 100644 index 000000000..662f9dd67 --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/out/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] + +[package] +name = "cargo-list-test-fixture" +version = "0.0.0" + +[dependencies] +aa = "0.0.0" diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/stderr.log b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/stderr.log new file mode 100644 index 000000000..760ca8b0f --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/stderr.log @@ -0,0 +1,2 @@ +warning: translating `cbindgen` to `aa` + Adding aa v0.0.0 to dependencies diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/stdout.log b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/stdout.log new file mode 100644 index 000000000..e69de29bb diff --git a/tests/testsuite/cargo_add/mod.rs b/tests/testsuite/cargo_add/mod.rs index 949f3a282..bf52f6e7f 100644 --- a/tests/testsuite/cargo_add/mod.rs +++ b/tests/testsuite/cargo_add/mod.rs @@ -1,5 +1,7 @@ mod add_basic; mod add_multiple; +mod add_no_vendored_package_with_alter_registry; +mod add_no_vendored_package_with_vendor; mod add_normalized_name_external; mod add_toolchain; mod build; From a31184b9eba1dafd4e3aac7b985faf623a55ca56 Mon Sep 17 00:00:00 2001 From: LuuuX Date: Thu, 22 Feb 2024 12:56:25 +0800 Subject: [PATCH 2/3] Added QueryKind::Normalized, and used it in cargo-add --- crates/resolver-tests/src/lib.rs | 1 + src/cargo/ops/cargo_add/mod.rs | 6 +++--- src/cargo/sources/directory.rs | 1 + src/cargo/sources/path.rs | 1 + src/cargo/sources/registry/mod.rs | 3 ++- src/cargo/sources/source.rs | 3 +++ .../add_no_vendored_package_with_vendor/in/Cargo.toml | 2 +- .../cargo_add/add_no_vendored_package_with_vendor/mod.rs | 2 +- .../add_no_vendored_package_with_vendor/out/Cargo.toml | 3 --- .../add_no_vendored_package_with_vendor/stderr.log | 3 +-- 10 files changed, 14 insertions(+), 11 deletions(-) diff --git a/crates/resolver-tests/src/lib.rs b/crates/resolver-tests/src/lib.rs index efd9cebc6..c1cabbe55 100644 --- a/crates/resolver-tests/src/lib.rs +++ b/crates/resolver-tests/src/lib.rs @@ -113,6 +113,7 @@ pub fn resolve_with_config_raw( let matched = match kind { QueryKind::Exact => dep.matches(summary), QueryKind::Fuzzy => true, + QueryKind::Normalized => true, }; if matched { self.used.insert(summary.package_id()); diff --git a/src/cargo/ops/cargo_add/mod.rs b/src/cargo/ops/cargo_add/mod.rs index 609793efa..9199b0e71 100644 --- a/src/cargo/ops/cargo_add/mod.rs +++ b/src/cargo/ops/cargo_add/mod.rs @@ -588,7 +588,7 @@ fn get_latest_dependency( } MaybeWorkspace::Other(query) => { let possibilities = loop { - match registry.query_vec(&query, QueryKind::Fuzzy) { + match registry.query_vec(&query, QueryKind::Normalized) { std::task::Poll::Ready(res) => { break res?; } @@ -711,7 +711,7 @@ fn select_package( MaybeWorkspace::Other(query) => { let possibilities = loop { // Exact to avoid returning all for path/git - match registry.query_vec(&query, QueryKind::Exact) { + match registry.query_vec(&query, QueryKind::Normalized) { std::task::Poll::Ready(res) => { break res?; } @@ -938,7 +938,7 @@ fn populate_available_features( } let possibilities = loop { - match registry.query_vec(&query, QueryKind::Exact) { + match registry.query_vec(&query, QueryKind::Normalized) { std::task::Poll::Ready(res) => { break res?; } diff --git a/src/cargo/sources/directory.rs b/src/cargo/sources/directory.rs index 01c3c4330..12f130100 100644 --- a/src/cargo/sources/directory.rs +++ b/src/cargo/sources/directory.rs @@ -109,6 +109,7 @@ impl<'cfg> Source for DirectorySource<'cfg> { let matches = packages.filter(|pkg| match kind { QueryKind::Exact => dep.matches(pkg.summary()), QueryKind::Fuzzy => true, + QueryKind::Normalized => dep.matches(pkg.summary()), }); for summary in matches.map(|pkg| pkg.summary().clone()) { f(IndexSummary::Candidate(summary)); diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index bbf6f056b..91f232cdc 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -555,6 +555,7 @@ impl<'cfg> Source for PathSource<'cfg> { let matched = match kind { QueryKind::Exact => dep.matches(s), QueryKind::Fuzzy => true, + QueryKind::Normalized => dep.matches(s), }; if matched { f(IndexSummary::Candidate(s.clone())) diff --git a/src/cargo/sources/registry/mod.rs b/src/cargo/sources/registry/mod.rs index f2f2bb037..6ce061ea5 100644 --- a/src/cargo/sources/registry/mod.rs +++ b/src/cargo/sources/registry/mod.rs @@ -793,6 +793,7 @@ impl<'cfg> Source for RegistrySource<'cfg> { let matched = match kind { QueryKind::Exact => dep.matches(s.as_summary()), QueryKind::Fuzzy => true, + QueryKind::Normalized => true, }; if !matched { return; @@ -831,7 +832,7 @@ impl<'cfg> Source for RegistrySource<'cfg> { return Poll::Ready(Ok(())); } let mut any_pending = false; - if kind == QueryKind::Fuzzy { + if kind == QueryKind::Fuzzy || kind == QueryKind::Normalized { // Attempt to handle misspellings by searching for a chain of related // names to the original name. The resolver will later // reject any candidates that have the wrong name, and with this it'll diff --git a/src/cargo/sources/source.rs b/src/cargo/sources/source.rs index dd6619e59..016be1423 100644 --- a/src/cargo/sources/source.rs +++ b/src/cargo/sources/source.rs @@ -180,6 +180,9 @@ pub enum QueryKind { /// whereas an `Registry` source may return dependencies that have the same /// canonicalization. Fuzzy, + /// Match a denpendency in all ways and will normalize the package name. + /// Each source defines what normalizing means. + Normalized, } /// A download status that represents if a [`Package`] has already been diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/Cargo.toml b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/Cargo.toml index cc2e9e100..3ecdb6681 100644 --- a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/Cargo.toml +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/Cargo.toml @@ -2,4 +2,4 @@ [package] name = "cargo-list-test-fixture" -version = "0.0.0" \ No newline at end of file +version = "0.0.0" diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/mod.rs b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/mod.rs index ba41a5896..e3ef32f9d 100644 --- a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/mod.rs +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/mod.rs @@ -15,7 +15,7 @@ fn case() { .arg_line("cbindgen") .current_dir(cwd) .assert() - .success() + .failure() .stdout_matches(file!["stdout.log"]) .stderr_matches(file!["stderr.log"]); diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/out/Cargo.toml b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/out/Cargo.toml index 662f9dd67..3ecdb6681 100644 --- a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/out/Cargo.toml +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/out/Cargo.toml @@ -3,6 +3,3 @@ [package] name = "cargo-list-test-fixture" version = "0.0.0" - -[dependencies] -aa = "0.0.0" diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/stderr.log b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/stderr.log index 760ca8b0f..fbe4bffe9 100644 --- a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/stderr.log +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/stderr.log @@ -1,2 +1 @@ -warning: translating `cbindgen` to `aa` - Adding aa v0.0.0 to dependencies +error: the crate `cbindgen` could not be found in registry index. From 640c0774dae2548cf9e8c5f4fc38790d421d5783 Mon Sep 17 00:00:00 2001 From: LuuuX Date: Thu, 22 Feb 2024 14:08:46 +0800 Subject: [PATCH 3/3] Rename Fuzzy to Alternatives --- crates/resolver-tests/src/lib.rs | 2 +- src/cargo/core/resolver/errors.rs | 2 +- src/cargo/sources/directory.rs | 2 +- src/cargo/sources/path.rs | 2 +- src/cargo/sources/registry/mod.rs | 4 ++-- src/cargo/sources/source.rs | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/resolver-tests/src/lib.rs b/crates/resolver-tests/src/lib.rs index c1cabbe55..8585abada 100644 --- a/crates/resolver-tests/src/lib.rs +++ b/crates/resolver-tests/src/lib.rs @@ -112,7 +112,7 @@ pub fn resolve_with_config_raw( for summary in self.list.iter() { let matched = match kind { QueryKind::Exact => dep.matches(summary), - QueryKind::Fuzzy => true, + QueryKind::Alternatives => true, QueryKind::Normalized => true, }; if matched { diff --git a/src/cargo/core/resolver/errors.rs b/src/cargo/core/resolver/errors.rs index 4ecce02b5..ed981ebe3 100644 --- a/src/cargo/core/resolver/errors.rs +++ b/src/cargo/core/resolver/errors.rs @@ -305,7 +305,7 @@ pub(super) fn activation_error( // Maybe the user mistyped the name? Like `dep-thing` when `Dep_Thing` // was meant. So we try asking the registry for a `fuzzy` search for suggestions. let candidates = loop { - match registry.query_vec(&new_dep, QueryKind::Fuzzy) { + match registry.query_vec(&new_dep, QueryKind::Alternatives) { Poll::Ready(Ok(candidates)) => break candidates, Poll::Ready(Err(e)) => return to_resolve_err(e), Poll::Pending => match registry.block_until_ready() { diff --git a/src/cargo/sources/directory.rs b/src/cargo/sources/directory.rs index 12f130100..055b00042 100644 --- a/src/cargo/sources/directory.rs +++ b/src/cargo/sources/directory.rs @@ -108,7 +108,7 @@ impl<'cfg> Source for DirectorySource<'cfg> { let packages = self.packages.values().map(|p| &p.0); let matches = packages.filter(|pkg| match kind { QueryKind::Exact => dep.matches(pkg.summary()), - QueryKind::Fuzzy => true, + QueryKind::Alternatives => true, QueryKind::Normalized => dep.matches(pkg.summary()), }); for summary in matches.map(|pkg| pkg.summary().clone()) { diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index 91f232cdc..fb70c34ba 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -554,7 +554,7 @@ impl<'cfg> Source for PathSource<'cfg> { for s in self.packages.iter().map(|p| p.summary()) { let matched = match kind { QueryKind::Exact => dep.matches(s), - QueryKind::Fuzzy => true, + QueryKind::Alternatives => true, QueryKind::Normalized => dep.matches(s), }; if matched { diff --git a/src/cargo/sources/registry/mod.rs b/src/cargo/sources/registry/mod.rs index 6ce061ea5..474a4279c 100644 --- a/src/cargo/sources/registry/mod.rs +++ b/src/cargo/sources/registry/mod.rs @@ -792,7 +792,7 @@ impl<'cfg> Source for RegistrySource<'cfg> { .query_inner(dep.package_name(), &req, &mut *self.ops, &mut |s| { let matched = match kind { QueryKind::Exact => dep.matches(s.as_summary()), - QueryKind::Fuzzy => true, + QueryKind::Alternatives => true, QueryKind::Normalized => true, }; if !matched { @@ -832,7 +832,7 @@ impl<'cfg> Source for RegistrySource<'cfg> { return Poll::Ready(Ok(())); } let mut any_pending = false; - if kind == QueryKind::Fuzzy || kind == QueryKind::Normalized { + if kind == QueryKind::Alternatives || kind == QueryKind::Normalized { // Attempt to handle misspellings by searching for a chain of related // names to the original name. The resolver will later // reject any candidates that have the wrong name, and with this it'll diff --git a/src/cargo/sources/source.rs b/src/cargo/sources/source.rs index 016be1423..eac6e49c3 100644 --- a/src/cargo/sources/source.rs +++ b/src/cargo/sources/source.rs @@ -179,7 +179,7 @@ pub enum QueryKind { /// Path/Git sources may return all dependencies that are at that URI, /// whereas an `Registry` source may return dependencies that have the same /// canonicalization. - Fuzzy, + Alternatives, /// Match a denpendency in all ways and will normalize the package name. /// Each source defines what normalizing means. Normalized,