-
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
Implement support for rust-version field in project metadata #8037
Conversation
r? @ehuss (rust_highfive has picked a reviewer for you, use r? to override) |
I don't have strong opinions about the name. As for dependency support, I think this check will need to be done elsewhere. I'm not sure if there is a perfect spot. Maybe immediately after the call to Other things to add to the todo list is:
I'm a bit confused why this is changing the Summary. Shouldn't it just be stored in the Package? The RFC mentioned "semver format without range operators". Do you happen to remember why? Unfortunately just checking a versionreq doesn't work well with pre-release identifiers like I can't think of a lot more tests to add. The only thing I can think of is to add some registry packages to exercise that. It looks like you added the field to the |
Why is this the case? |
From the RFC:
(Not clear how much sense this makes if we end up picking a different version.) |
@ehuss reverted the changes to I added the feature-gating, too, but I'm currently unsure how to then enable this feature for the tests. Any help there appreciated. |
In the tests, you need to call For the manifest, you need to add |
☔ The latest upstream changes (presumably #8073) made this pull request unmergeable. Please resolve the merge conflicts. |
e422dfd
to
1dc7ec8
Compare
☔ The latest upstream changes (presumably #8068) made this pull request unmergeable. Please resolve the merge conflicts. |
@ehuss this seems like a decent MVP to merge. Please have another look. |
tests/testsuite/rust_version.rs
Outdated
.with_status(101) | ||
.with_stderr( | ||
"\ | ||
error: package `bar` cannot be built because it requires rustc ^1.2345.0, while the currently active rustc version is [..] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, the caret here might be confusing for some people, particularly those not very familiar with Cargo or semver requirements. Perhaps if the message could say something like "... it requires rustc 1.2345.0 or newer, ...".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. This required a bit of surgery, with the result that the manifest propagates the value as a string, which gets checked for correctness (including parsing as VersionReq
) when the manifest gets ingested, but is parsed again when checking in cargo_compile, where I unwrap()
the error (since this is checked earlier). Is that okay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, I think so. If it's a problem later, it can be changed.
☔ The latest upstream changes (presumably #8167) made this pull request unmergeable. Please resolve the merge conflicts. |
Don't we need check for |
That was explicitly scoped out of RFC 2495. |
Ping @djc: do you think you'll be able to address the comments and rebase on master? |
I think for this, we don't need a specific For nightly/unstable features, there are two independent opt-in mechanisms. The
There is a bit of documentation on this at https://doc.crates.io/contrib/process/unstable.html and in the features module. As for centralizing the argument, there are a set of arguments that are essentially the same for every "build-like" command. That is:
So we don't have to fuss with ensuring that these commands always include the right options, I was thinking it would be nice just to have an
It's up to you if you want to do that. Otherwise, just make sure the list above is covered by |
cf62dc7
to
688a9aa
Compare
I have not grouped the build common options in this PR, I might do a follow-up to improve the situation there. |
From the RFC:
I don't know if/how to implement this. I think Cargo will now still error if the unstable field gets used. I could restrict it for now to not allow it to be smaller than 1.51, if that makes sense, but that version should eventually probably be adjusted to the version that stabilizes this field. |
Thanks! As for the 1.27 floor, I think the intent is: let's say it gets stabilized in version 1.60. A project whose MSRV is 1.35 can specify 1.35 in the manifest to make it clear what their MSRV is. Even though older versions will ignore it, I think it makes sense to specify the actual version instead of the version when it first starts getting honored. However, thinking about that more, I think if this gets merged now, that means that versions starting with 1.51 will never be able to use this setting, because Cargo will complain about an unstable feature. I'm concerned that this will make it very difficult to use for a long time (until a project's MSRV reaches whenever it is stabilized, which could be a year or more). Since this feature is fundamentally about improving MSRV support, I think that may be a bad way to start it off. This key is not critical (it doesn't actually change anything). I'm thinking instead of calling if features.require(Feature::rust_version()).is_err() {
warnings.push(
"`rustc-version` is not supposed on this version of Cargo and will be ignored"
.to_string(),
);
} Maybe include a check to I think that should be safe to do, it will just print a warning just like any other unknown key. |
Resolved your final comments and changed the error to warn (including tests for both nightly and stable). |
Looks good, thanks! 🎉 @bors r+ |
📌 Commit c221fec has been approved by |
Thanks for the reviews! |
☀️ Test successful - checks-actions |
Include rust-version in publish request crates.io reads rust-version from the tarball directly, but we can include it in the publish request for the sake of consistency for third-party registries. See [relevant Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/318791-t-crates-io/topic/rust-version.20field). Validation for the field was already implemented in #8037.
Needs a bunch more work, but I'd like some early feedback! Remaining work:
rust-version
here overmsrv
ormin-rust-version
)run
,verify
andpublish
subcommandsMinimal version of @moxian's earlier take in #7801.
cc rust-lang/rust#65262