Skip to content
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

Extend -Zpackage-features with more capabilities. #8074

Merged
merged 2 commits into from
Apr 9, 2020

Conversation

ehuss
Copy link
Contributor

@ehuss ehuss commented Apr 5, 2020

This is a proposal to extend -Zpackage-features with new abilities to change how features are selected on the command-line. See unstable.md for documentation on what it does.

I've contemplated a variety of ways we could transition this to stable. I tried a few experiments trying to make a "transition with warnings" mode, but I'm just too concerned about breaking backwards compatibility. The current way is just fundamentally different from the new way, and I think it would be a bumpy ride to try to push it.

The stabilization story is that the parts of this that add new functionality (feature flags in virtual worskpaces, and member/feat syntax) can be stabilized at any time. The change for cargo build -p member --features feat in a different member's directory can maybe be part of -Zfeatures stabilization, which will need to be opt-in. I've been trying to come up with some transition plan, and I can't think of a way without making it opt-in, and making it part of -Zfeatures is an opportunity to simplify things. One concern is that this might be confusing (--features flag could behave differently in different workspaces, and documenting the differences), but that seems hard to avoid.

Closes #6195
Closes #4753
Closes #5015
Closes #4106
Closes #5362

@rust-highfive
Copy link

r? @Eh2406

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 5, 2020
Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

So as we go further down this path I'm thinking more about the roll-out story for this. What would you think of removing all the various -Z flags we have today and instead roll everything into something like -Zfeatures2 for a "features 2.0 feature". Or, perhaps better yet, move it into the manifest as a cargo-features-gated field in [package]?

I'm basically curious if we can move closer to "all we need to do is flip a switch" territory with something we're comfortable rolling out. I'm worried now that to understand the full story of how we envision enabling all this you've gotta understand a lot of various -Z flags and how they interact

enables matching features. It is still an error if none of the packages
define a given feature.
* `--features` and `--no-default-features` are now allowed in the root of a
virtual workspace.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To confirm, these flags, when applied in this scenario, would be applied to all workspace members, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

@@ -330,6 +330,7 @@ pub struct CliUnstable {
pub avoid_dev_deps: bool,
pub minimal_versions: bool,
pub package_features: bool,
pub package_features2: bool,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you worried about breakage if we change the existing unstable feature package_features? I'd be ok with simply updating that since we're more likely to stabilize this than that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with merging them (will do that soonish). I wanted to get feedback first, and keeping them separate was a way to highlight how they differ.

@alexcrichton
Copy link
Member

Oh I should also mention that these proposed semantics for the -p and --features flags sound great to me 👍

@ehuss
Copy link
Contributor Author

ehuss commented Apr 6, 2020

"all we need to do is flip a switch"

Yea, that's the eventual plan. I could accelerate that, maybe after merging this? I was keeping them separate because each option had different implementation concerns and trade-offs.

I think we discussed earlier of making it a flag in the [workspace] table, since feature resolution is done workspace-wide. The problem with [package] is that it would be ignored in a workspace (can't "unify" for a single package), and there needs to be somewhere to specify it in a virtual manifest.

However, [workspace] isn't exactly ideal. For example, Cargo itself wouldn't be able to use it because of the lack of nested workspaces in rust-lang/rust. I think it would also be interesting if some point in the future cargo new defaulted to the new mode, but being part of [workspace] makes that more complicated. Every new project would have additional [workspace] boilerplate, and cargo new would need to check if it is already in a workspace.

Those concerns may not be dealbreakers. I think we should sooner or later support nested workspaces. And I think cargo new already checks for workspaces, though it is a little awkward.

@alexcrichton
Copy link
Member

Oh sure yeah no need to conflate it here. I'm largely just worried that it's difficult to get real-world impact data/testing given the changing set of flags over time, but hey that's to be expected while things are worked on :)

Perhaps we should start a dedicated issue for how to roll out the new features features?

@ehuss ehuss changed the title Implement -Zpackage-features2 Implement -Zpackage-features Apr 8, 2020
@ehuss ehuss changed the title Implement -Zpackage-features Extend -Zpackage-features with more capabilities. Apr 8, 2020
@ehuss
Copy link
Contributor Author

ehuss commented Apr 8, 2020

I pushed an update removing the new -Z flag and just using the old one.

I also added a comment on the old tracking issue to try to solicit feedback.

Filed #8088 for a meta-tracking issue.

@alexcrichton
Copy link
Member

@bors: r+

👍

@bors
Copy link
Contributor

bors commented Apr 9, 2020

📌 Commit 54ace8a has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 9, 2020
@bors
Copy link
Contributor

bors commented Apr 9, 2020

⌛ Testing commit 54ace8a with merge 3a976c1...

@bors
Copy link
Contributor

bors commented Apr 9, 2020

☀️ Test successful - checks-azure
Approved by: alexcrichton
Pushing 3a976c1 to master...

@bors bors merged commit 3a976c1 into rust-lang:master Apr 9, 2020
@jethrogb
Copy link
Contributor

jethrogb commented Apr 9, 2020

Did you really mean to close all of these? #6195 #4753 #5015 #4106 #5362

@ehuss
Copy link
Contributor Author

ehuss commented Apr 9, 2020

Yes. This is the solution to all of them, unless you see something that is not covered?

@jethrogb
Copy link
Contributor

jethrogb commented Apr 9, 2020

I might be mistaken, but I believe normally issues are not closed until the feature is stabilized?

@ehuss
Copy link
Contributor Author

ehuss commented Apr 9, 2020

Normally the issues are closed and a tracking issue is opened for stabilization (#5364 in this case). (In the case of an RFC, we reuse the original RFC tracking issue.) When it is stabilized, #5364 will be closed.

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 14, 2020
Update cargo

12 commits in 390e8f245ef2cd7ac698b8a76abf029f9abcab0d..74e3a7d5b756d7c0e94399fc29fcd154e792c22a
2020-04-07 17:46:45 +0000 to 2020-04-13 20:41:52 +0000
- Update dependencies to support illumos target (rust-lang/cargo#8093)
- Whitelist another known spurious curl error (rust-lang/cargo#8102)
- Fix nightly test matching rustc "warning" output. (rust-lang/cargo#8098)
- Update default for codegen-units. (rust-lang/cargo#8096)
- Fix freshness when linking is interrupted. (rust-lang/cargo#8087)
- Add `cargo tree` command. (rust-lang/cargo#8062)
- Add "build-finished" JSON message. (rust-lang/cargo#8069)
- Extend -Zpackage-features with more capabilities. (rust-lang/cargo#8074)
- Disallow invalid dependency names through crate renaming (rust-lang/cargo#8090)
- Use the same filename hash for pre-release channels. (rust-lang/cargo#8073)
- Index the commands section (rust-lang/cargo#8081)
- Upgrade to mdBook v0.3.7 (rust-lang/cargo#8083)
@ehuss ehuss added this to the 1.44.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment