refactor: drop yanked_whitelist from source loading#17014
Conversation
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`.
|
r? @epage rustbot has assigned @epage. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
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 One half-developed idea is that |
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. |
### 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 |
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)
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)
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)
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)
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::loadwas the only place that passed a real listso we do a post construction after
PackageRegistryinload.The parameter was only load-bearing for
PackageRegistry.How to test and review this PR?
This has no user-facing behavior change.