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

Add support for new feature syntax (RFC 3143) #3867

Merged
merged 3 commits into from
Dec 30, 2021
Merged

Conversation

ehuss
Copy link
Contributor

@ehuss ehuss commented Aug 25, 2021

This adds support for the new feature syntax described in RFC 3143. There are two new feature values that are allowed in the [features] table: weak dependencies (foo?/feat-name) and namespaced dependencies (dep:bar). When these style of features are detected, they are placed in the index in a separate field called features2 to prevent older versions of cargo from breaking on them. Additionally, it sets a new version field called v to indicate that this new field is present, which prevents versions starting at 1.51 from selecting those versions.

@rust-highfive
Copy link

r? @smarnach

(rust-highfive has picked a reviewer for you, use r? to override)

src/git.rs Show resolved Hide resolved
@Turbo87 Turbo87 added A-backend ⚙️ C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works labels Aug 27, 2021
src/git.rs Show resolved Hide resolved
Copy link

@pksunkara pksunkara left a comment

Choose a reason for hiding this comment

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

Looks good except for a minor concern

src/models/krate.rs Show resolved Hide resolved
@bors
Copy link
Contributor

bors commented Oct 28, 2021

☔ The latest upstream changes (presumably #4096) made this pull request unmergeable. Please resolve the merge conflicts.

@djc
Copy link

djc commented Dec 21, 2021

Gentle ping? I think this should be labeled as waiting on review again?

Copy link
Member

@jhpratt jhpratt left a comment

Choose a reason for hiding this comment

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

I can't attest to the validity of the changes as a whole; I'm not familiar with the internals. The parsing of the feature seems correct. Just one minor nit on style.

src/models/krate.rs Outdated Show resolved Hide resolved
@Turbo87
Copy link
Member

Turbo87 commented Dec 22, 2021

FWIW we discussed this on Discord a few days ago: https://discord.com/channels/442252698964721669/448525639469891595/920823792631152691

the tl;dr is that we show features on the UI these days and we need to verify that this still works correctly with this new syntax

@ehuss
Copy link
Contributor Author

ehuss commented Dec 23, 2021

the tl;dr is that we show features on the UI these days and we need to verify that this still works correctly with this new syntax

I'm not sure how you'd like to verify that. I could add something that did a database query in the features_version_2 test if you'd like.

The feature values themselves don't seem to be displayed in the UI:

image

I can confirm from the API that it is there:

curl http://localhost:4200/api/v1/crates/foo | jq .versions[0].features
{
  "f1": [
    "dep:bar"
  ],
  "f2": [
    "bar?/bar-feat"
  ]
}

And via psql:

cargo_registry=# select * from versions;
 id | crate_id |  num  |         updated_at         |         created_at         | downloads |                   features                   | yanked | license | crate_size | published_by
----+----------+-------+----------------------------+----------------------------+-----------+----------------------------------------------+--------+---------+------------+--------------
  1 |        1 | 0.1.0 | 2021-12-22 23:49:25.411573 | 2021-12-22 23:49:25.411573 |         0 | {}                                           | f      | MIT     |        702 |            1
  2 |        2 | 0.1.0 | 2021-12-22 23:51:35.513816 | 2021-12-22 23:51:35.513816 |         0 | {"bar-feat": []}                             | f      | MIT     |        719 |            1
  4 |        1 | 0.2.0 | 2021-12-22 23:56:47.374767 | 2021-12-22 23:56:47.374767 |         0 | {"f1": ["dep:bar"], "f2": ["bar?/bar-feat"]} | f      | MIT     |        772 |            1
(3 rows)

Copy link
Member

@Turbo87 Turbo87 left a comment

Choose a reason for hiding this comment

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

The feature values themselves don't seem to be displayed in the UI

you're absolutely right. now that I finally had time to take a detailed look at the RFC and PR changes, I agree that the frontend shouldn't be affected by this. since the split between features and features2 only happens for the index, but is otherwise kept in its merged form I don't see any issues with it.

nice work! and sorry for the huge review delay... 😞

@pietroalbini @jtgeibel unless you have any objections I plan to merge this on 2021-12-30 (one week from now), or earlier if you both signal your approval until then :)

@Turbo87
Copy link
Member

Turbo87 commented Dec 30, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Dec 30, 2021

📌 Commit 2b4430c has been approved by Turbo87

@bors
Copy link
Contributor

bors commented Dec 30, 2021

⌛ Testing commit 2b4430c with merge 91a2cd4...

@bors
Copy link
Contributor

bors commented Dec 30, 2021

☀️ Test successful - checks-actions
Approved by: Turbo87
Pushing 91a2cd4 to master...

@bors bors merged commit 91a2cd4 into rust-lang:master Dec 30, 2021
@Turbo87
Copy link
Member

Turbo87 commented Dec 30, 2021

rebased, merged and deployed. thanks for working on this @ehuss!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-backend ⚙️ C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants