-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shortest path #12678
Shortest path #12678
Conversation
r? @epage (rustbot has picked a reviewer for you, use r? to override) |
a484f27
to
1051246
Compare
code fixed. History rewritten. And test added. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to r= when its ready
@@ -164,7 +164,7 @@ pub fn resolve_with_config_raw( | |||
// we found a case that causes a panic and did not use all of the input. | |||
// lets print the part of the input that was used for minimization. | |||
eprintln!( | |||
"{:?}", | |||
"Part used befor drop: {:?}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: before
rather than befor
1051246
to
679d651
Compare
@bors r=epage |
☀️ Test successful - checks-actions |
Update cargo 19 commits in b4ddf95ad9954118ac0dae835f2966394ad04c02..414d9e3a6d8096f3e276234ce220c868767a8792 2023-09-18 03:48:09 +0000 to 2023-09-22 07:03:57 +0000 - refactor(TomlManifest): fail when package_root is not a directory (rust-lang/cargo#12722) - Better suggestion for unsupported mode in build command (rust-lang/cargo#12693) - Update curl-sys to pull in curl 8.3.0 (rust-lang/cargo#12718) - chore(ci): Ignore patch version in MSRV (rust-lang/cargo#12716) - refactor: move cached crates.io SourceID to config module (rust-lang/cargo#12711) - fix: typos in registry authentication documentation (rust-lang/cargo#12714) - doc: mention unstable flag `-Z asymmetric-token` (rust-lang/cargo#12712) - fix: copy PDBs for EFI targets (rust-lang/cargo#12688) - infra: add auto-trigger rules for new labels (rust-lang/cargo#12713) - fix: use channel-specific link for registry auth error (rust-lang/cargo#12709) - Add some enhancements to `cargo clean` (rust-lang/cargo#12638) - chore: Fix typos (rust-lang/cargo#12707) - Shortest path (rust-lang/cargo#12678) - doc/reference/manifest: Adjust `keywords` description (rust-lang/cargo#12705) - Cargo add displays either feature list or summarized count (rust-lang/cargo#12702) - SemVer: Update documentation about removing optional dependencies (rust-lang/cargo#12687) - publish.py: Remove obsolete `sleep()` calls (rust-lang/cargo#12686) - generalise suggestion on abiguous spec (rust-lang/cargo#12685) - util/toml: Remove duplicate `serde(rename)` attributes (rust-lang/cargo#12682) r? ghost
Update cargo 19 commits in b4ddf95ad9954118ac0dae835f2966394ad04c02..414d9e3a6d8096f3e276234ce220c868767a8792 2023-09-18 03:48:09 +0000 to 2023-09-22 07:03:57 +0000 - refactor(TomlManifest): fail when package_root is not a directory (rust-lang/cargo#12722) - Better suggestion for unsupported mode in build command (rust-lang/cargo#12693) - Update curl-sys to pull in curl 8.3.0 (rust-lang/cargo#12718) - chore(ci): Ignore patch version in MSRV (rust-lang/cargo#12716) - refactor: move cached crates.io SourceID to config module (rust-lang/cargo#12711) - fix: typos in registry authentication documentation (rust-lang/cargo#12714) - doc: mention unstable flag `-Z asymmetric-token` (rust-lang/cargo#12712) - fix: copy PDBs for EFI targets (rust-lang/cargo#12688) - infra: add auto-trigger rules for new labels (rust-lang/cargo#12713) - fix: use channel-specific link for registry auth error (rust-lang/cargo#12709) - Add some enhancements to `cargo clean` (rust-lang/cargo#12638) - chore: Fix typos (rust-lang/cargo#12707) - Shortest path (rust-lang/cargo#12678) - doc/reference/manifest: Adjust `keywords` description (rust-lang/cargo#12705) - Cargo add displays either feature list or summarized count (rust-lang/cargo#12702) - SemVer: Update documentation about removing optional dependencies (rust-lang/cargo#12687) - publish.py: Remove obsolete `sleep()` calls (rust-lang/cargo#12686) - generalise suggestion on abiguous spec (rust-lang/cargo#12685) - util/toml: Remove duplicate `serde(rename)` attributes (rust-lang/cargo#12682) r? ghost
Update cargo 19 commits in b4ddf95ad9954118ac0dae835f2966394ad04c02..414d9e3a6d8096f3e276234ce220c868767a8792 2023-09-18 03:48:09 +0000 to 2023-09-22 07:03:57 +0000 - refactor(TomlManifest): fail when package_root is not a directory (rust-lang/cargo#12722) - Better suggestion for unsupported mode in build command (rust-lang/cargo#12693) - Update curl-sys to pull in curl 8.3.0 (rust-lang/cargo#12718) - chore(ci): Ignore patch version in MSRV (rust-lang/cargo#12716) - refactor: move cached crates.io SourceID to config module (rust-lang/cargo#12711) - fix: typos in registry authentication documentation (rust-lang/cargo#12714) - doc: mention unstable flag `-Z asymmetric-token` (rust-lang/cargo#12712) - fix: copy PDBs for EFI targets (rust-lang/cargo#12688) - infra: add auto-trigger rules for new labels (rust-lang/cargo#12713) - fix: use channel-specific link for registry auth error (rust-lang/cargo#12709) - Add some enhancements to `cargo clean` (rust-lang/cargo#12638) - chore: Fix typos (rust-lang/cargo#12707) - Shortest path (rust-lang/cargo#12678) - doc/reference/manifest: Adjust `keywords` description (rust-lang/cargo#12705) - Cargo add displays either feature list or summarized count (rust-lang/cargo#12702) - SemVer: Update documentation about removing optional dependencies (rust-lang/cargo#12687) - publish.py: Remove obsolete `sleep()` calls (rust-lang/cargo#12686) - generalise suggestion on abiguous spec (rust-lang/cargo#12685) - util/toml: Remove duplicate `serde(rename)` attributes (rust-lang/cargo#12682) r? ghost
Update cargo 19 commits in b4ddf95ad9954118ac0dae835f2966394ad04c02..414d9e3a6d8096f3e276234ce220c868767a8792 2023-09-18 03:48:09 +0000 to 2023-09-22 07:03:57 +0000 - refactor(TomlManifest): fail when package_root is not a directory (rust-lang/cargo#12722) - Better suggestion for unsupported mode in build command (rust-lang/cargo#12693) - Update curl-sys to pull in curl 8.3.0 (rust-lang/cargo#12718) - chore(ci): Ignore patch version in MSRV (rust-lang/cargo#12716) - refactor: move cached crates.io SourceID to config module (rust-lang/cargo#12711) - fix: typos in registry authentication documentation (rust-lang/cargo#12714) - doc: mention unstable flag `-Z asymmetric-token` (rust-lang/cargo#12712) - fix: copy PDBs for EFI targets (rust-lang/cargo#12688) - infra: add auto-trigger rules for new labels (rust-lang/cargo#12713) - fix: use channel-specific link for registry auth error (rust-lang/cargo#12709) - Add some enhancements to `cargo clean` (rust-lang/cargo#12638) - chore: Fix typos (rust-lang/cargo#12707) - Shortest path (rust-lang/cargo#12678) - doc/reference/manifest: Adjust `keywords` description (rust-lang/cargo#12705) - Cargo add displays either feature list or summarized count (rust-lang/cargo#12702) - SemVer: Update documentation about removing optional dependencies (rust-lang/cargo#12687) - publish.py: Remove obsolete `sleep()` calls (rust-lang/cargo#12686) - generalise suggestion on abiguous spec (rust-lang/cargo#12685) - util/toml: Remove duplicate `serde(rename)` attributes (rust-lang/cargo#12682) r? ghost
If the only path is a loop then counted as the shortest path. This is a fix for #12941 This graph data structure is used to store dependency DAGs. Where each edge represents a dependency from a package to the package that fulfilled the dependency. Different parts of the resolver store this data in opposite directions, sometimes packages point at the things that depend on them other times packages point to the parents that required them. Error messages often need to report on why a package is in the graph, either by walking up toward parents or down toward children depending on how this graph is stored. #12678 unified the two different walking implementations, and replace them with a breadth first search so as to find the shortest path. This code ignored when edge pointed at a package that had already been reached, because that generally describes a longer path to an existing package. Unfortunately, when I said this was a DAG that was a simplification. There can be cycles introduced as dev-dependencies. The existing code would reasonably ignore the cycles figuring that if we continue searching we would eventually find the root package (a package that nothing depended on). Missing the possibility that the root package created the cycle. Now we search through the entire graph looking for a root package. If we do not find a root package we report the path to the last package we processed.
What does this PR try to resolve?
Currently error messages from the resolver are based a random path from a package that couldn't be resolved back to the root package. It was pointed out to me that the shortest route is likely to be more useful so the switches to using breadth first search to pick the path. There is also one re-factor to use let-else that I spotted while doing this work.
How should we test and review this PR?
The shortest path is is a random path, so this is not technically a behavioral change. As such the tests still pass is good evidence for being reasonable.