-
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
Refactor resolve Method
#7186
Refactor resolve Method
#7186
Conversation
r? @Eh2406 (rust_highfive has picked a reviewer for you, use r? to override) |
src/cargo/core/resolver/resolve.rs
Outdated
metadata: Metadata, | ||
/// `[patch]` entries that did not match anything, preserved in | ||
/// `Cargo.lock` as the `[[patch.unused]]` table array. | ||
/// TODO: *Why* is this kept in `Cargo.lock`? Removing it doesn't seem to |
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.
I couldn't figure out the purpose of unused_patches
, any ideas?
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.
Looks like it was added in #4123 if that helps...
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.
One of the features of [patch]
is that it ends up needing to resolve all the dependencies all the time. This means that if we didn't record unused patch entries in Cargo.lock
then every time you type cargo build
Cargo would "Updating registry ..." and take a lot longer on each build. (it's not guaranteed this would happen but it's very likely this would happen)
By recording unused [patch]
entries in the lock file we can ensure that all subsequent cargo build
have a guaranteed resolution of what's in the manifest (so long as it hasn't changed) so we won't ever have to re-update the registry and we can get nice, quick, deterministic builds.
You can sort of think of it like adding an entry to [dependencies]
but you don't actually use it, just in this case we know whether it's used or not.
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.
Ah, that makes sense! Thanks for the explanation.
Thank you very much! This definitely makes things clearer! Having skimmed it it all looks good. |
@bors r=alexcrichton |
📌 Commit abf2bb4 has been approved by |
Refactor resolve `Method` This changes the enum `Method` to a struct called `ResolveOpts`. The intent is to try to make it a little easier to read and understand. If this doesn't actually look better to anyone, I'm fine with discarding this (I can resubmit just with documentation). It only seems marginally better, but I have had difficulty with understanding the subtleties of `Method` for a while. I wasn't able to measure any performance difference. This also has a few other changes: - Adds some documentation. - Removes `resolve_ws_precisely`, cutting down the number of resolve functions from 4 to 3.
☀️ Test successful - checks-azure |
Update cargo, rls ## cargo 12 commits in d0f828419d6ce6be21a90866964f58eb2c07cd56..26092da337b948719549cd5ed3d1051fd847afd7 2019-07-23 21:58:59 +0000 to 2019-07-31 23:24:32 +0000 - tests: Enable features to fix unstabilized `#[bench]` (rust-lang/cargo#7198) - Fix excluding target dirs from backups on OSX (rust-lang/cargo#7192) - Handle symlinks to directories (rust-lang/cargo#6817) - Enable pipelined compilation by default (rust-lang/cargo#7143) - Refactor resolve `Method` (rust-lang/cargo#7186) - Update `cargo_compile` module doc. (rust-lang/cargo#7187) - Clean up TargetInfo (rust-lang/cargo#7185) - Fix some issues with absolute paths in dep-info files. (rust-lang/cargo#7137) - Update the `url` crate to 2.0 (rust-lang/cargo#7175) - Tighten requirements for git2 crates (rust-lang/cargo#7176) - Fix a deadlocking test with master libgit2 (rust-lang/cargo#7179) - Fix detection of cyclic dependencies through `[patch]` (rust-lang/cargo#7174) ## rls 1 commits in 70347b5d4dfe78eeb9e6f6db85f773c8d43cd22b..93d9538c6000fcf6c8da763ef4ce7a8d407b7d24 2019-07-30 12:56:38 +0200 to 2019-07-31 21:42:49 +0200 - Update cargo (rust-lang/rls#1529)
Remove debug panic in package-features. I accidentally left a debug panic in #7186. This adds a test to exercise this code path.
This also updates the docs.rs codebase to account for this cargo change: rust-lang/cargo#7186
This changes the enum
Method
to a struct calledResolveOpts
. The intent is to try to make it a little easier to read and understand.If this doesn't actually look better to anyone, I'm fine with discarding this (I can resubmit just with documentation). It only seems marginally better, but I have had difficulty with understanding the subtleties of
Method
for a while. I wasn't able to measure any performance difference.This also has a few other changes:
resolve_ws_precisely
, cutting down the number of resolve functions from 4 to 3.