-
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
Features 2.0 meta tracking issue. #8088
Comments
For rolling out, I think I might actually propose a scheme such as:
I think that should satisfy all our constraints, except for maybe being a nice system. The reason I propose this is the fourth bullet, though, where eventually we do not want to require this configuration and instead we will simply want to infer it from an [package]
edition = "2021"
[workspace]
edition = "2021" in the next edition. So given that constraint that we want to infer it from |
I might be reluctant to use Hm, what about just allowing some cargo-features = ["features2"]
[package]
name = "foo"
# … Or we could rename that, since the word "feature" is so overloaded. Top-level things don't work as well in a virtual manifest if we want to make it part of the next edition. Unless we move the edition field to the root. I think with looking at every workspace member, it could be too easy to accidentally introduce a global change. Imagine a large workspace with lots of different people working on it, someone introduces a new tool or library with |
I would slightly prefer in terms of bikeshedding that this is placed in I agree that changing any package with this flag (or using I'm personally relatively wary of trying to make |
Add `resolver` opt-in for new feature resolver. This adds a new `resolver` field to `Cargo.toml` to provide an opt-in mechanism for backwards-incompatible resolver changes. This enables the new feature resolver and `-Zpackage-features`. See `unstable.md` for documentation. cc #8088
The new opt-in mechanism is now on nightly: cargo-features = ["resolver"]
[package]
name = "my-package"
version = "1.0.0"
resolver = "2" See the docs for more details: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#resolver |
So I just tried this out in one of my projects where I have a virtual workspace at the root and a bunch of crates in subdirectories. If I understand correctly, I only need to set the resolver in the workspace, not in the individual crates. However when I do that, I get a bunch of warnings from cargo:
Is this the expected behavior? Do I need to specifically override the resolver for all crates in the workspace? |
Nah, it looks like the warning detection is just horribly broken. It is intended that you only specify it in the root |
I left some glowing praise for the resolver 2 behavior in a comment on the |
Seems to work for me as well in a use case similar to @cbiffle when using |
…hton Allow configuring unstable flags via config file # Summary This fixes #8127 by mapping the `unstable` key in `.cargo/config` to Z flags. It should have no impact on stable/beta cargo, and on nightlies it gives folks the ability to configure Z flags for an entire project or workspace. This is meant to make it easier to try things like the [new features resolver](#8088) behavior, mtime-on-use, build-std, or timing reports across a whole project. I've also included a small (but entirely independent) ergonomics change -- treating dashes and underscores identically in Z flags. That's along for the ride in this PR as the last commit, and is included here because it makes for more idiomatic toml file keys (`print_im_a_teapot = yes` vs `print-im-a-teapot = yes`). Please let me know if y'all would prefer that be in a separate PR, or not happen at all. # Test Plan Apologies if I've missed anything -- this is my first cargo contrib and I've tried to hew to the contributing guide. If I've slipped up, please let me know how and I'll fix it. NB. My linux machine doesn't have multilib set up, so I disabled cross tests. * `cargo test` passes for each commit in the stack * I formatted each commit in the stack with `rustfmt` * New tests are included alongside the relevant change for each change * I've validated each test by locally undoing the code change they support and confirming failure. * The CLI wins, for both enable and disabling Z flags, as you'd expect. Keys in `unstable` which do not correspond with a Z flag will trigger an error indicating the invalid flag came from a config file read: ``` Invalid [unstable] entry in Cargo config Caused by: unknown `-Z` flag specified: an-invalid-flag ``` If you'd like to see a test case which isn't represented here, I'm happy to add it. Just let me know. # Documentation I've included commits in this stack updating the only docs page that seemed relevant to me, skimming the book -- `unstable.md`.
* "resolver" feature is needed * rust-lang/cargo#8088
This is a tracking issue for a collection of changes to features that we are considering rolling out together.
-Z features=itarget
— Ignoring inactive targets.-Z features=host_dep
— Decoupling features of normal deps from host deps (build dependencies and proc-macros).-Z features=dev_dep
— Decoupling features of dev-dependencies from normal builds.--feature
+--package
combination #5364-Z package-features
— Better ways to select workspace features on the command-line.The current idea is to add a flag to
[workspace]
to opt-in to the new behavior for all of these at once.The text was updated successfully, but these errors were encountered: