-
Notifications
You must be signed in to change notification settings - Fork 0
Show the merged set of activated features to the user when inheriting… #1
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
Conversation
src/cargo/ops/cargo_add/mod.rs
Outdated
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 think a unknown_features.extend(req_feats.different(...)) would b clearer than the for_each approach
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 run into issues with &&str not living long enough. You can transition things to String but then you introduce .to_string() and .clone()
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.
Try unknown_features.extend(req_feats.different(...).copied())
src/cargo/ops/cargo_add/mod.rs
Outdated
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.
This won't recursively activate features.
Instead add this into activated before we do the VecDeque and the rest of the code should just work out
src/cargo/ops/cargo_add/mod.rs
Outdated
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.
This isn't sorting the workspace features in with the regular ones and will look confusing.
If you merge into the activated features, this shouldn't be needed anymore
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.
Can you change this to
[features]
default-base = []
default-test-base = []
default-merge-base = []
default = ["default-base", "default-test-base", "default-merge-base"]
test-base = []
test = ["test-base", "default-test-base"]
merge-base = []
merge = ["merge-base", "default-merge-base"]
unrelated = []This will
- Show we recursively activate all
- Don't duplicate activations
- Don't just enable everything :)
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.
Why is this dead_code?
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 believe I just copied this from above. I'll remove it
… from a workspace dependency
02a5439 to
55cf27e
Compare
Cargo add support for workspace inheritance Tracking issue: #8415 RFC: rust-lang/rfcs#2906 This PR adds all the required support for workspace inheritance within `cargo-add`. It was split up across a few different PRs as it required `snapbox` support from #10581 and a new `toml_edit` version from #10603. `@epage` and I decided to go ahead with this PR and add in some of the changes those PRs made. `@epage's` name on the commits is from helping to rewrite commits and some very minor additions. Changes: - #10585 - Muscraft#1 - Muscraft#3 - Muscraft#2 - Muscraft#4 r? `@epage`
…st-lang#15405) Resolves rust-lang#15401 Here is an example of the feature in [kitty](https://sw.kovidgoyal.net/kitty/) `0.40.1` with the following config set in `~/.config/kitty/kitty.conf` ```conf underline_hyperlinks always show_hyperlink_targets yes allow_hyperlinks yes # ... ```  Tested on `uname -a`: ``` Linux nixos 6.14.0 #1-NixOS SMP PREEMPT_DYNAMIC Mon Mar 24 14:02:41 UTC 2025 x86_64 GNU/Linux ``` Terminals tested with: - [x] [kitty](https://sw.kovidgoyal.net/kitty/) `0.40.1` - [x] [ghostty](https://ghostty.org/) `1.1.4-6f1b22a-nix`  - [x] [alacritty](https://alacritty.org/index.html) `0.15.1`  - [x] VScode's version `1.98` integrated terminal aka. [xterm.js](https://xtermjs.org/)  The following `cargo` invocations will have their output be modified by this change: ```shell cargo run # If multiple binaries are defined in the manifest and [package.default-bin] is not defined cargo run --bin cargo run --example cargo run --package cargo build --bin cargo build --example cargo build --package cargo test --test cargo test --bench ``` In addition I have done a slight refactor to have the printed indent of targets and packages be the same by using a shared constant named `const ITEM_INDENT: &str = " ";` This is my first PR to the cargo codebase, so I am not familiar with what is expected in terms of test for a feature such as this. <!-- Thanks for submitting a pull request 🎉! Here are some tips for you: * If this is your first contribution, read "Cargo Contribution Guide" first: https://doc.crates.io/contrib/ * Run `cargo fmt --all` to format your code changes. * Small commits and pull requests are always preferable and easy to review. * If your idea is large and needs feedback from the community, read how: https://doc.crates.io/contrib/process/#working-on-large-features * Cargo takes care of compatibility. Read our design principles: https://doc.crates.io/contrib/design.html * When changing help text of cargo commands, follow the steps to generate docs: https://github.com/rust-lang/cargo/tree/master/src/doc#building-the-man-pages * If your PR is not finished, set it as "draft" PR or add "WIP" in its title. * It's ok to use the CI resources to test your PR, but please don't abuse them. ### What does this PR try to resolve? Explain the motivation behind this change. A clear overview along with an in-depth explanation are helpful. You can use `Fixes #<issue number>` to associate this PR to an existing issue. ### How should we test and review this PR? Demonstrate how you test this change and guide reviewers through your PR. With a smooth review process, a pull request usually gets reviewed quicker. If you don't know how to write and run your tests, please read the guide: https://doc.crates.io/contrib/tests ### Additional information Other information you want to mention in this PR, such as prior arts, future extensions, an unresolved problem, or a TODO list. -->
rust-lang#15966) ### What does this PR try to resolve? This change considers public dependencies when adding a new dependency. For example, if you depend on `foo`, which depends publicly on `bar 1.0`, and you run `cargo add bar`, you will now get `bar 1.0` even if `bar 2.0` is available. Fixes rust-lang#13038 ### How to test and review this PR? The test suite has been updated with an example scenario. More tests might be warrented to see how this interacts with other features though.
### What does this PR try to resolve? Switches to a version of openssl-src that works on sparc64-unknown-linux-gnu. This makes it easier to build cargo for that platform as you no longer need to build OpenSSL by hand first. ### How to test and review this PR? On PopOS 22.04 x86-64: ```console $ sudo apt install gcc-sparc64-linux-gnu $ RUSTFLAGS="-Clinker=sparc64-linux-gnu-gcc" \ CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc \ cargo build --target=sparc64-unknown-linux-gnu --features=vendored-openssl --release $ scp ./target/sparc64-unknown-linux-gnu/release/cargo user@sparc-machine: $ ssh user@sparc-machine uname -a Linux sparc-machine 6.17.0-rc5+ #1 SMP Fri Sep 12 20:37:32 UTC 2025 sparc64 GNU/Linux $ ssh user@sparc-machine ./cargo -V cargo 1.92.0 (85a3813 2025-10-22) ```
Tracking issue: rust-lang#8415
RFC: rust-lang/rfcs#2906
PRs in this RFC:
Cargo.tomlrust-lang/cargo#10517license-path, anddepednency.pathrust-lang/cargo#10538readmerust-lang/cargo#10548rust-versionrust-lang/cargo#10563excludeandincluderust-lang/cargo#10565workspaceto… rust-lang/cargo#10564InheritableFieldsin aLazyCellinside `… rust-lang/cargo#10568key.workspace = truetokey = { workspace = true }rust-lang/cargo#10584cargo-addsupportcargo add foowhen afoo.workspace = truealready exists rust-lang/cargo#10585Changes:
inheritable_featurestocargo_add::Dependencyprint_msgto print outinheritable_featuresas neededinheritable_featuresinside of available_featuresRemaining implementation work for the RFC
cargo-addsupport, see epage's commentr? @epage