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

Unify weak and namespaced features. #9574

Merged
merged 1 commit into from
Jun 22, 2021
Merged

Conversation

ehuss
Copy link
Contributor

@ehuss ehuss commented Jun 11, 2021

This unifies weak and namespaced features in order to simplify the syntax and semantics. Previously there were four different ways to specify the feature of a dependency:

  • package-name/feature-name — Enables feature package-name on self and enables feature-name on the dependency. (Today's behavior.)
  • package-name?/feature-name — Only enables feature-name on the given package if it that package is enabled and will also activates a feature named package-name (which must be defined implicitly or explicitly).
  • dep:package-name/feature-name — Enables dependency package-name, and enables feature-name on that dependency. This does NOT enable a feature named "package-name".
  • dep:package-name?/feature-name — Only enables feature-name on the given package if it that package is enabled. This does NOT enable a feature named "package-name".

This changes it so there are only two:

  • package-name/feature-name — Today's behavior.
  • package-name?/feature-name — Only enables feature-name on the given package if it that package is enabled. This does NOT enable a feature named "package-name" (the same behavior as dep:package-name?/feature-name above).

This is a fairly subtle change, and in most cases probably won't be noticed. However, it simplifies things which helps with writing documentation and explaining how it works.

@rust-highfive
Copy link

r? @alexcrichton

(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 Jun 11, 2021
@djc
Copy link
Contributor

djc commented Jun 11, 2021

So if I understand this correctly, you never need the dep prefix on feature dependencies because using a feature implies that the part before the slash is a dependency?

@ehuss
Copy link
Contributor Author

ehuss commented Jun 11, 2021

Yea, that's the idea.

@djc
Copy link
Contributor

djc commented Jun 11, 2021

Sounds good then, nice simplification!

@alexcrichton alexcrichton added the T-cargo Team: Cargo label Jun 14, 2021
@alexcrichton
Copy link
Member

👍

@rfcbot fcp merge

@rfcbot
Copy link
Collaborator

rfcbot commented Jun 14, 2021

Team member @alexcrichton has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period An FCP proposal has started, but not yet signed off. disposition-merge FCP with intent to merge labels Jun 14, 2021
@rfcbot
Copy link
Collaborator

rfcbot commented Jun 14, 2021

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot added final-comment-period FCP — a period for last comments before action is taken and removed proposed-final-comment-period An FCP proposal has started, but not yet signed off. labels Jun 14, 2021
@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Collaborator

bors commented Jun 22, 2021

📌 Commit 9034e48 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 Jun 22, 2021
@bors
Copy link
Collaborator

bors commented Jun 22, 2021

⌛ Testing commit 9034e48 with merge a2589dd...

@bors
Copy link
Collaborator

bors commented Jun 22, 2021

☀️ Test successful - checks-actions
Approved by: alexcrichton
Pushing a2589dd to master...

@bors bors merged commit a2589dd into rust-lang:master Jun 22, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jun 24, 2021
Update cargo

This also updates `opener` used in bootstrap (to try to keep dependencies unified).

18 commits in 44456677b5d1d82fe981c955dc5c67734b31f340..9233aa06c801801cff75df65df718d70905a235e
2021-06-12 18:00:01 +0000 to 2021-06-22 21:32:55 +0000
- Detect incorrectly named cargo.toml (rust-lang/cargo#9607)
- Unify weak and namespaced features. (rust-lang/cargo#9574)
- Change `rustc-cdylib-link-arg` error to a warning. (rust-lang/cargo#9563)
- Updates to future-incompatible reporting. (rust-lang/cargo#9606)
- Add a compatibility notice for diesel and the new resolver. (rust-lang/cargo#9602)
- Don't allow config env to modify vars set by cargo (rust-lang/cargo#9579)
- Disambiguate is_symlink. (rust-lang/cargo#9604)
- Update opener requirement from 0.4 to 0.5 (rust-lang/cargo#9583)
- Avoid quadratic complexity when splitting output into lines (rust-lang/cargo#9586)
- Bump to 0.56.0, update changelog (rust-lang/cargo#9597)
- Fix dep-info files including non-local build script paths. (rust-lang/cargo#9596)
- Relax doc collision error. (rust-lang/cargo#9595)
- Handle "jobs = 0" case in cargo config files (rust-lang/cargo#9584)
- Enhancements to testsuite error output. (rust-lang/cargo#9589)
- Fix typo (rust-lang/cargo#9590)
- Enable support for fix --edition for 2021. (rust-lang/cargo#9588)
- Add more details for installing git repository errors (rust-lang/cargo#9582)
- More information for links conflicting (rust-lang/cargo#9568)
@rfcbot rfcbot added finished-final-comment-period FCP complete and removed final-comment-period FCP — a period for last comments before action is taken labels Jun 24, 2021
@ehuss ehuss added this to the 1.55.0 milestone Feb 6, 2022
bors added a commit that referenced this pull request Oct 3, 2022
Provide a better error message when mixing dep: with /

Features of the form `dep:foo/feature` aren't accepted as valid syntax. This generated a somewhat confusing error message of:

```
feature `f1` includes `dep:bar/bar-feat`, but `dep:bar` is not a dependency
```

This PR adds a more targeted error message that provides some suggestions on how to fix it.

There is more context in #9574 as to why the syntax is the way it is.
bors added a commit that referenced this pull request May 12, 2023
Fix dep/feat syntax with hidden implicit optional dependencies

This fixes an issue with `dep/feat` syntax in the `[features]` table where it wouldn't work if the optional dependency had its implicit feature removed via the `dep:` syntax.

The problem is that both resolvers were expecting that `dep/feat` would be able to activate a feature named "dep". But if that implicit feature wasn't created, then it would fail with an error.

This was just an oversight (which probably happened in #9574).

Fixes #10788
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-merge FCP with intent to merge finished-final-comment-period FCP complete S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-cargo Team: Cargo to-announce
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants