Skip to content

Commit 4d7913b

Browse files
committed
refactor(source): Qualify what alternatives we look for
1 parent a451139 commit 4d7913b

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

crates/resolver-tests/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ pub fn resolve_with_global_context_raw(
143143
for summary in self.list.iter() {
144144
let matched = match kind {
145145
QueryKind::Exact => dep.matches(summary),
146-
QueryKind::Alternatives => true,
146+
QueryKind::AlternativeNames => true,
147147
QueryKind::Normalized => true,
148148
};
149149
if matched {

src/cargo/core/resolver/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ pub(super) fn activation_error(
304304
// Maybe the user mistyped the name? Like `dep-thing` when `Dep_Thing`
305305
// was meant. So we try asking the registry for a `fuzzy` search for suggestions.
306306
let candidates = loop {
307-
match registry.query_vec(&new_dep, QueryKind::Alternatives) {
307+
match registry.query_vec(&new_dep, QueryKind::AlternativeNames) {
308308
Poll::Ready(Ok(candidates)) => break candidates,
309309
Poll::Ready(Err(e)) => return to_resolve_err(e),
310310
Poll::Pending => match registry.block_until_ready() {

src/cargo/sources/directory.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl<'gctx> Source for DirectorySource<'gctx> {
109109
let packages = self.packages.values().map(|p| &p.0);
110110
let matches = packages.filter(|pkg| match kind {
111111
QueryKind::Exact => dep.matches(pkg.summary()),
112-
QueryKind::Alternatives => true,
112+
QueryKind::AlternativeNames => true,
113113
QueryKind::Normalized => dep.matches(pkg.summary()),
114114
});
115115
for summary in matches.map(|pkg| pkg.summary().clone()) {

src/cargo/sources/path.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl<'gctx> Source for PathSource<'gctx> {
146146
if let Some(s) = self.package.as_ref().map(|p| p.summary()) {
147147
let matched = match kind {
148148
QueryKind::Exact => dep.matches(s),
149-
QueryKind::Alternatives => true,
149+
QueryKind::AlternativeNames => true,
150150
QueryKind::Normalized => dep.matches(s),
151151
};
152152
if matched {
@@ -333,7 +333,7 @@ impl<'gctx> Source for RecursivePathSource<'gctx> {
333333
{
334334
let matched = match kind {
335335
QueryKind::Exact => dep.matches(s),
336-
QueryKind::Alternatives => true,
336+
QueryKind::AlternativeNames => true,
337337
QueryKind::Normalized => dep.matches(s),
338338
};
339339
if matched {

src/cargo/sources/registry/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ impl<'gctx> Source for RegistrySource<'gctx> {
804804
dep.matches(s.as_summary())
805805
}
806806
}
807-
QueryKind::Alternatives => true,
807+
QueryKind::AlternativeNames => true,
808808
QueryKind::Normalized => true,
809809
};
810810
if !matched {
@@ -839,7 +839,7 @@ impl<'gctx> Source for RegistrySource<'gctx> {
839839
return Poll::Ready(Ok(()));
840840
}
841841
let mut any_pending = false;
842-
if kind == QueryKind::Alternatives || kind == QueryKind::Normalized {
842+
if kind == QueryKind::AlternativeNames || kind == QueryKind::Normalized {
843843
// Attempt to handle misspellings by searching for a chain of related
844844
// names to the original name. The resolver will later
845845
// reject any candidates that have the wrong name, and with this it'll
@@ -859,7 +859,7 @@ impl<'gctx> Source for RegistrySource<'gctx> {
859859
.query_inner(name_permutation, &req, &mut *self.ops, &mut |s| {
860860
if !s.is_yanked() {
861861
f(s);
862-
} else if kind == QueryKind::Alternatives {
862+
} else if kind == QueryKind::AlternativeNames {
863863
f(s);
864864
}
865865
})?

src/cargo/sources/source.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ pub enum QueryKind {
185185
/// Path/Git sources may return all dependencies that are at that URI,
186186
/// whereas an `Registry` source may return dependencies that have the same
187187
/// canonicalization.
188-
Alternatives,
188+
AlternativeNames,
189189
/// Match a dependency in all ways and will normalize the package name.
190190
/// Each source defines what normalizing means.
191191
Normalized,

0 commit comments

Comments
 (0)