Add infrastructure for nightly features and flags#4433
Add infrastructure for nightly features and flags#4433bors merged 2 commits intorust-lang:masterfrom
Conversation
|
r? @matklad (rust_highfive has picked a reviewer for you, use r? to override) |
|
cc @rust-lang/cargo |
matklad
left a comment
There was a problem hiding this comment.
Looks good to me, only cosmetic comments!
src/bin/bench.rs
Outdated
There was a problem hiding this comment.
It's possible that it's better to hide this from help, just to avoid having the unstable word in the help for the main Rust tool, but looks like this can be difficult to achieve with docopt, so we can just skip it altogether.
There was a problem hiding this comment.
Yeah that's how I felt, and another use case for not using docopt eventually!
src/bin/cargo.rs
Outdated
There was a problem hiding this comment.
Hm, let's allow directly on flag_z fields perhaps? Alternatively, docopt uses serde now, so perhaps we can have flag_z and rename it to flag_Z on serde level?
src/cargo/core/features.rs
Outdated
There was a problem hiding this comment.
Super great comment! 💯 💯 💯 👍
src/cargo/core/features.rs
Outdated
There was a problem hiding this comment.
*(feature.get)(self) looks cryptic. Why do we return &bool? :)
I would try to write it like this probably:
if feature.is_enabled(self) {
return Ok(())
}
// bail here
src/cargo/util/toml/mod.rs
Outdated
There was a problem hiding this comment.
Would unwrap_or(&[]) work here?
There was a problem hiding this comment.
Oh that just required munging around with Option<&Vec<T>> -> Option<&[T]> which was just a pain.
tests/cargo-features.rs
Outdated
There was a problem hiding this comment.
Let's add a similar test, when a feature is activated in a dependency, and not in in the current crate. We should reject unstable dependencies for stable crates.
There was a problem hiding this comment.
Ah right yeah meant to add a test for that
|
cc @carols10cents. I hope you'll reach consensus about crates.io side of the things :) |
7ff2fbb to
88b2f42
Compare
88b2f42 to
f26fc37
Compare
|
Addressed review comments |
|
@bors r+ |
|
📌 Commit f26fc37 has been approved by |
Add infrastructure for nightly features and flags This PR starts adding infrastructure in Cargo for nightly features and nightly flags. The current design looks like: * There's a new `package.cargo-features` manifest key which accepts an array of strings. This array of strings is the list of enabled Cargo features for that crate. * A new suite of flags behind `-Z`, like the compiler, are accepted on the command line for all commands. * Features and unstable flags in Cargo are required to be used on Cargo's nightly channel, which is the same as Rust's nightly channel. * Features and unstable flags cannot be used on the stable/beta channels of Rust/Cargo. * Crates which enable features in their manifest are disallowed from being published to crates.io The motivation behind this support is unblock a number of efforts in Cargo by allowing them to safely get implemented behind a nightly feature gate. Once behind a feature gate they can iterate in-tree without having to worry about "insta stability" and we can also get valuable usage feedback about upstream users. Closes #4409
|
☀️ Test successful - status-appveyor, status-travis |
|
Yay this landed!! @aturon sorry I never found time to patch in with the planning of this. |
|
@alexcrichton I've tried to use nightly features to experiment with "optimized dependencies", but faced a problem: virtual manifests do not support cargo features, and it's not trivial to add support for them, because currently What do you think about moving |
|
@matklad seems reasonable to me! |
|
Ok, then are we bound by some backwards compat concerns here? This shipped 24 days ago, have it hit beta? |
|
Nah nothing AFAIK is using this yet, so we can change it as we like |
This PR starts adding infrastructure in Cargo for nightly features and nightly flags. The current design looks like:
package.cargo-featuresmanifest key which accepts an array of strings. This array of strings is the list of enabled Cargo features for that crate.-Z, like the compiler, are accepted on the command line for all commands.The motivation behind this support is unblock a number of efforts in Cargo by allowing them to safely get implemented behind a nightly feature gate. Once behind a feature gate they can iterate in-tree without having to worry about "insta stability" and we can also get valuable usage feedback about upstream users.
Closes #4409