Skip to content

Commit 5df493e

Browse files
committed
fix(add): Don't select yanked versions when normalizing names
Fixes #14893
1 parent 737a5e8 commit 5df493e

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

src/cargo/sources/registry/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,13 @@ impl<'gctx> Source for RegistrySource<'gctx> {
856856
}
857857
any_pending |= self
858858
.index
859-
.query_inner(name_permutation, &req, &mut *self.ops, f)?
859+
.query_inner(name_permutation, &req, &mut *self.ops, &mut |s| {
860+
if !s.is_yanked() {
861+
f(s);
862+
} else if kind == QueryKind::Alternatives {
863+
f(s);
864+
}
865+
})?
860866
.is_pending();
861867
}
862868
}

tests/testsuite/cargo_add/normalize_name_registry_yanked/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn case() {
2323
.arg_line("linked_hash_map")
2424
.current_dir(cwd)
2525
.assert()
26-
.failure()
26+
.success()
2727
.stdout_eq(str![""])
2828
.stderr_eq(file!["stderr.term.svg"]);
2929

tests/testsuite/cargo_add/normalize_name_registry_yanked/out/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
name = "cargo-list-test-fixture"
55
version = "0.0.0"
66
edition = "2015"
7+
8+
[dependencies]
9+
linked-hash-map = "0.5.4"

tests/testsuite/cargo_add/normalize_name_registry_yanked/stderr.term.svg

Lines changed: 5 additions & 4 deletions
Loading

0 commit comments

Comments
 (0)