cognitive-engineering-lab / rustc_plugin

A framework for writing plugins that integrate with the Rust compiler
MIT License
135 stars 16 forks source link

Can use use semver metadata/pre-release for Crates.io #1

Closed Eh2406 closed 1 year ago

Eh2406 commented 1 year ago

In the readme:

The extra nightly metadata breaks Cargo's semver rules, so we won't be publishing to crates.io.

With an example of "nightly-2023-04-12-v0.1.4", which is not a valid semver version. But "0.1.4+nightly-2023-04-12" is a valid semver using the metadata part of semver. Or "0.1.4-nightly-2023-04-12" using the pre-release part of semver. https://regex101.com/r/DTge1n/1

willcrichton commented 1 year ago

You're right in that I can use the semver metadata field. I wrote that line based on this excerpt from the Cargo book:

SemVer has the concept of "version metadata" with a plus in the version, such as 1.0.0+21AF26D3. This metadata is usually ignored, and should not be used in a version requirement. You should never publish multiple versions that differ only in the metadata tag (note, this is a known issue with crates.io that currently permits this).

My reasoning was that I want rustc-plugin users to have to explicitly list their nightly version in the version requirement. However, if Cargo ignores the metadata in version requirements, then aspect is not enforced.

Eh2406 commented 1 year ago

That makes sense. If you publish version "0.1.4+nightly-2023-04-12" then users of the crate would depend on it with "0.1.4" which does not remind them that it only works with one version of nightly.

pre-release may be a better fit. "0.1.4-nightly-2023-04-12" can only to be depended on if an = requirement is used and prerelease is present. So "=0.1.4-nightly-2023-04-12" will work but "=0.1.4" will not.

willcrichton commented 1 year ago

I just changed the release model to use the prerelease tags as you suggested @Eh2406. Thanks for the help!