-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Remove disabled optional weak dependencies when resolving #16424
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
base: master
Are you sure you want to change the base?
Conversation
|
r? @weihanglo rustbot has assigned @weihanglo. Use |
This comment has been minimized.
This comment has been minimized.
|
I won't be up for reviewing the core part of this, so my comments are a pre-review. Please clean up commits for how they should be reviewed and merged. r? @Eh2406 |
tests/testsuite/weak_dep_features.rs
Outdated
| // Maybe `cargo tree` should print a note about why? | ||
| p.cargo("tree -e features -i bar --features bar?/feat") | ||
| .with_stdout_data("") | ||
| .with_status(101) |
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.
Technically, this is a breaking change though we'll have to evaluate our willingness to accept this
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.
Due to the new resolver is gated, cargo now restore its old behavior. I reverted this change.
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.
The root cause is that I remove the non-activated weak dependency from root crate, too.
Now weak direct dependency is always included in Cargo.lock, with its test disabled_weak_direct_dep.
Previous change to tree and other tests is removed permanently.
0845b68 to
b1733c6
Compare
src/cargo/ops/resolve.rs
Outdated
| &version_prefs, | ||
| ResolveVersion::with_rust_version(ws.lowest_rust_version()), | ||
| Some(ws.gctx()), | ||
| version, |
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.
Isn't this redundant with line 512?
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.
You are right, I missed this. Now it's fixed.
b1733c6 to
7bf935f
Compare
|
I haven't done a review of the approach, I wonder whether this supports the |
7bf935f to
1b71270
Compare
It passed. I port 4 tests from your pull request, and |
1b71270 to
29008b4
Compare
…eeded Signed-off-by: Jackhr-arch <63526062+Jackhr-arch@users.noreply.github.com>
Signed-off-by: Jackhr-arch <63526062+Jackhr-arch@users.noreply.github.com>
Signed-off-by: Jackhr-arch <63526062+Jackhr-arch@users.noreply.github.com>
Co-authored-by: @est31 Signed-off-by: Jackhr-arch <63526062+Jackhr-arch@users.noreply.github.com>
29008b4 to
53f926c
Compare
I am not a native English user, please forgive my flaws in description.
What does this PR try to resolve?
it changes the parts of the resolver that generate Cargo.lock to not include weak dependencies.
This changes the logic when resolver checking features. Instead of add weak feature as strong one, now resolver keeps the weak dependency features until the very dependency is checked. Then it combines the weak features with the original ones.
E.g.
Now resolver acts like:
then it works on weak dependency features.
(here reslover enabled the weak feat)
(here reslover ignore the weak feat)
Relate to #10801
How to test and review this PR?
I've enabled some tests in
crates/resolver-testsrelating toWeak dependenciesand looks they work fine.Here is an example repo https://github.com/Jackhr-arch/cargo-weak-dep-feat-example