Skip to content

refactor: drop yanked_whitelist from source loading#17014

Merged
epage merged 1 commit into
rust-lang:masterfrom
weihanglo:allowlist
Jun 5, 2026
Merged

refactor: drop yanked_whitelist from source loading#17014
epage merged 1 commit into
rust-lang:masterfrom
weihanglo:allowlist

Conversation

@weihanglo

Copy link
Copy Markdown
Member

What does this PR try to resolve?

Split off from #17012 for an easier review experience I guess.

Most call sites constructed with an empty allowlist,
and PackageRegistry::load was the only place that passed a real list
so we do a post construction after PackageRegistry in load.
The parameter was only load-bearing for PackageRegistry.

How to test and review this PR?

This has no user-facing behavior change.

Most call sites constructed with an empty allowlist,
and `PackageRegistry::load` was the only place that passed a real list
so we do a post construction after PackageRegistry construction in `load`.
The parameter was only load-bearing for `PackageRegistry`.
@rustbot rustbot added A-future-incompat Area: future incompatible reporting A-interacts-with-crates.io Area: interaction with registries A-registries Area: registries Command-install Command-publish Command-vendor S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 19, 2026
@rustbot

rustbot commented May 19, 2026

Copy link
Copy Markdown
Collaborator

r? @epage

rustbot has assigned @epage.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ehuss, @epage, @weihanglo
  • @ehuss, @epage, @weihanglo expanded to ehuss, epage, weihanglo
  • Random selection from ehuss, epage

@epage

epage commented May 19, 2026

Copy link
Copy Markdown
Contributor

On its own, this is likely fine and I would be fine reviewing and merging if you want but I wonder if we should go in a different direction for the motivating case behind this.

I worry about the complexity that has grown around yanked as we have added features around it, like --precise and that grows stronger in considering doing something similar for other features like min-publish-age.

One half-developed idea is that Source has no knowledge about yanked but passes up the enum of different types of summaries. VersionPreferences would then decide whether to filter out yanked items or not. One possible way of doing this is for anything in VersionPreferences that is preferred is implicitly blessed for yanked, min publish age, etc.

@weihanglo

Copy link
Copy Markdown
Member Author

On its own, this is likely fine and I would be fine reviewing and merging if you want but I wonder if we should go in a different direction for the motivating case behind this.

While the original motivation of this PR wasn't about the larger refactor, removing whitelist from Source would always happen if we are going to move yanking behavior up to resolver. This refactor somehow minimizes future diff from touching too many files. Still worth merging I guess.

@epage epage added this pull request to the merge queue Jun 5, 2026
Merged via the queue into rust-lang:master with commit 71b70c0 Jun 5, 2026
46 of 58 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 5, 2026
@weihanglo weihanglo deleted the allowlist branch June 6, 2026 13:28
pull Bot pushed a commit to Mu-L/cargo that referenced this pull request Jun 10, 2026
### What does this PR try to resolve?

This PR moves move yank policy to resolver layer from source layer.

We mostly preserve the old `Source::query` behavior that filter out
yanked by default.

The yanking policy logic doesn't go into `VersionPreferences` or
`sort_summaries` yet because

* We want to minimize the refactor change. Changing the order of query
and filter may change existing diagnostics
* `[replace]` resolution should not see yanked candidates either
* A future `VersionPreferences` predicate may still need to be invoked
at this same point.

cc rust-lang#17012,
rust-lang#17014 (comment)

### How to test and review this PR?

Three tests are added to pin down more existing tests, along with
rust-lang#17082

Here is the list of all call site I audit:

| Call site | Yanked versions handling |
| --------- | ------------------------ |
| [`core/resolver/dep_cache.rs`
`query`](https://github.com/rust-lang/cargo/blob/71b70c095bb15e278ab9f0f808397c8033079888/src/cargo/core/resolver/dep_cache.rs#L64)
| Filter |
| [`core/resolver/dep_cache.rs` `[replace]`
override](https://github.com/rust-lang/cargo/blob/71b70c095bb15e278ab9f0f808397c8033079888/src/cargo/core/resolver/dep_cache.rs#L91)
| Filter |
| [`core/registry.rs` `patch`
collection](https://github.com/rust-lang/cargo/blob/71b70c095bb15e278ab9f0f808397c8033079888/src/cargo/core/registry.rs#L383)
| Filter |
| [`core/registry.rs`
`query_overrides`](https://github.com/rust-lang/cargo/blob/71b70c095bb15e278ab9f0f808397c8033079888/src/cargo/core/registry.rs#L553)
| Filter |
| [`core/registry.rs` `summary_for_patch`
unlocked-retry](https://github.com/rust-lang/cargo/blob/71b70c095bb15e278ab9f0f808397c8033079888/src/cargo/core/registry.rs#L965)
| Filter |
| [`core/registry.rs` `summary_for_patch` name-only
diagnostic](https://github.com/rust-lang/cargo/blob/71b70c095bb15e278ab9f0f808397c8033079888/src/cargo/core/registry.rs#L998)
| Filter |
| [`core/resolver/errors.rs`
`alt_versions`](https://github.com/rust-lang/cargo/blob/71b70c095bb15e278ab9f0f808397c8033079888/src/cargo/core/resolver/errors.rs#L432)
| Filter |
| [`core/resolver/errors.rs`
`rejected_versions`](https://github.com/rust-lang/cargo/blob/71b70c095bb15e278ab9f0f808397c8033079888/src/cargo/core/resolver/errors.rs#L450)
| Keep |
| [`core/resolver/errors.rs`
`alt_names`](https://github.com/rust-lang/cargo/blob/71b70c095bb15e278ab9f0f808397c8033079888/src/cargo/core/resolver/errors.rs#L469)
| Keep |
| [`ops/common_for_install_and_uninstall.rs` `select_dep_pkg`
(x2)](https://github.com/rust-lang/cargo/blob/71b70c095bb15e278ab9f0f808397c8033079888/src/cargo/ops/common_for_install_and_uninstall.rs#L611)
| Filter |
| [`ops/cargo_update.rs`
`upgrade_dependency`](https://github.com/rust-lang/cargo/blob/71b70c095bb15e278ab9f0f808397c8033079888/src/cargo/ops/cargo_update.rs#L373)
| Filter |
| [`ops/cargo_update.rs` `report_latest`
(x4)](https://github.com/rust-lang/cargo/blob/71b70c095bb15e278ab9f0f808397c8033079888/src/cargo/ops/cargo_update.rs#L791)
| Filter |
| [`ops/cargo_add/mod.rs`
`get_latest_dependency`](https://github.com/rust-lang/cargo/blob/71b70c095bb15e278ab9f0f808397c8033079888/src/cargo/ops/cargo_add/mod.rs#L823)
| Filter |
| [`ops/cargo_add/mod.rs`
`select_package`](https://github.com/rust-lang/cargo/blob/71b70c095bb15e278ab9f0f808397c8033079888/src/cargo/ops/cargo_add/mod.rs#L952)
| Filter |
| [`ops/cargo_add/mod.rs`
`populate_available_features`](https://github.com/rust-lang/cargo/blob/71b70c095bb15e278ab9f0f808397c8033079888/src/cargo/ops/cargo_add/mod.rs#L1180)
| Filter |
| [`ops/registry/info/mod.rs`
`query_summaries`](https://github.com/rust-lang/cargo/blob/71b70c095bb15e278ab9f0f808397c8033079888/src/cargo/ops/registry/info/mod.rs#L215)
| Filter |
| [`ops/registry/publish.rs`
`poll_one_package`](https://github.com/rust-lang/cargo/blob/71b70c095bb15e278ab9f0f808397c8033079888/src/cargo/ops/registry/publish.rs#L439)
| Filter |
| [`ops/registry/publish.rs`
`verify_unpublished`](https://github.com/rust-lang/cargo/blob/71b70c095bb15e278ab9f0f808397c8033079888/src/cargo/ops/registry/publish.rs#L451)
| Filter |
| [`core/compiler/future_incompat.rs`
`get_updates`](https://github.com/rust-lang/cargo/blob/71b70c095bb15e278ab9f0f808397c8033079888/src/cargo/core/compiler/future_incompat.rs#L334)
| Filter |
| [`crates/xtask-bump-check/src/xtask.rs`
`check`](https://github.com/rust-lang/cargo/blob/71b70c095bb15e278ab9f0f808397c8033079888/crates/xtask-bump-check/src/xtask.rs#L448)
| Filter |
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Jun 11, 2026
Update cargo submodule

11 commits in 0b1123a48825309b697312b44fdb64b3df00c958..fe63976b245b8a649c3f2949bf89fdc307bfbae4
2026-06-01 21:20:28 +0000 to 2026-06-11 09:17:57 +0000
- refactor: reduce use `Summary::{as_summary,into_summary}` (rust-lang/cargo#17092)
- docs(diag): Provide jumping off points for writing diagnostics and passes (rust-lang/cargo#17090)
- refactor(source): drop `Source::is_yanked` (rust-lang/cargo#17091)
- refactor(resolver): move yank policy to resolver layer  (rust-lang/cargo#17083)
- fix(publish): avoid false deadlock when to_confirm is non-empty (rust-lang/cargo#17071)
- doc(guide): use fresh actions/checkout version in GH actions examples (rust-lang/cargo#17087)
- fix: strip CR from `cargo:token-from-stdout` (rust-lang/cargo#17081)
- test: show some odd `--precise` cases (rust-lang/cargo#17082)
- chore(deps): update rust crate gix to 0.84.0 (rust-lang/cargo#17063)
- refactor: drop `yanked_whitelist` from source loading (rust-lang/cargo#17014)
- chore(deps): update msrv to v1.96 (rust-lang/cargo#17041)
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Jun 11, 2026
Update cargo submodule

11 commits in 0b1123a48825309b697312b44fdb64b3df00c958..fe63976b245b8a649c3f2949bf89fdc307bfbae4
2026-06-01 21:20:28 +0000 to 2026-06-11 09:17:57 +0000
- refactor: reduce use `Summary::{as_summary,into_summary}` (rust-lang/cargo#17092)
- docs(diag): Provide jumping off points for writing diagnostics and passes (rust-lang/cargo#17090)
- refactor(source): drop `Source::is_yanked` (rust-lang/cargo#17091)
- refactor(resolver): move yank policy to resolver layer  (rust-lang/cargo#17083)
- fix(publish): avoid false deadlock when to_confirm is non-empty (rust-lang/cargo#17071)
- doc(guide): use fresh actions/checkout version in GH actions examples (rust-lang/cargo#17087)
- fix: strip CR from `cargo:token-from-stdout` (rust-lang/cargo#17081)
- test: show some odd `--precise` cases (rust-lang/cargo#17082)
- chore(deps): update rust crate gix to 0.84.0 (rust-lang/cargo#17063)
- refactor: drop `yanked_whitelist` from source loading (rust-lang/cargo#17014)
- chore(deps): update msrv to v1.96 (rust-lang/cargo#17041)
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Jun 11, 2026
Update cargo submodule

11 commits in 0b1123a48825309b697312b44fdb64b3df00c958..fe63976b245b8a649c3f2949bf89fdc307bfbae4
2026-06-01 21:20:28 +0000 to 2026-06-11 09:17:57 +0000
- refactor: reduce use `Summary::{as_summary,into_summary}` (rust-lang/cargo#17092)
- docs(diag): Provide jumping off points for writing diagnostics and passes (rust-lang/cargo#17090)
- refactor(source): drop `Source::is_yanked` (rust-lang/cargo#17091)
- refactor(resolver): move yank policy to resolver layer  (rust-lang/cargo#17083)
- fix(publish): avoid false deadlock when to_confirm is non-empty (rust-lang/cargo#17071)
- doc(guide): use fresh actions/checkout version in GH actions examples (rust-lang/cargo#17087)
- fix: strip CR from `cargo:token-from-stdout` (rust-lang/cargo#17081)
- test: show some odd `--precise` cases (rust-lang/cargo#17082)
- chore(deps): update rust crate gix to 0.84.0 (rust-lang/cargo#17063)
- refactor: drop `yanked_whitelist` from source loading (rust-lang/cargo#17014)
- chore(deps): update msrv to v1.96 (rust-lang/cargo#17041)
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Jun 11, 2026
Update cargo submodule

11 commits in 0b1123a48825309b697312b44fdb64b3df00c958..fe63976b245b8a649c3f2949bf89fdc307bfbae4
2026-06-01 21:20:28 +0000 to 2026-06-11 09:17:57 +0000
- refactor: reduce use `Summary::{as_summary,into_summary}` (rust-lang/cargo#17092)
- docs(diag): Provide jumping off points for writing diagnostics and passes (rust-lang/cargo#17090)
- refactor(source): drop `Source::is_yanked` (rust-lang/cargo#17091)
- refactor(resolver): move yank policy to resolver layer  (rust-lang/cargo#17083)
- fix(publish): avoid false deadlock when to_confirm is non-empty (rust-lang/cargo#17071)
- doc(guide): use fresh actions/checkout version in GH actions examples (rust-lang/cargo#17087)
- fix: strip CR from `cargo:token-from-stdout` (rust-lang/cargo#17081)
- test: show some odd `--precise` cases (rust-lang/cargo#17082)
- chore(deps): update rust crate gix to 0.84.0 (rust-lang/cargo#17063)
- refactor: drop `yanked_whitelist` from source loading (rust-lang/cargo#17014)
- chore(deps): update msrv to v1.96 (rust-lang/cargo#17041)
@rustbot rustbot added this to the 1.98.0 milestone Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-future-incompat Area: future incompatible reporting A-interacts-with-crates.io Area: interaction with registries A-registries Area: registries Command-install Command-publish Command-vendor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants