Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #14305 - linyihai:matches-prerelease-semantic, r=epage
feat: Add matches_prerelease semantic ### What does this PR try to resolve? One implementaion for #13290 Thanks to `@Eh2406` feedback, a working version came out, and I think it should be able to test under the nightly feature. This PR proposes a `matches_prerelease semantic`. | req | matches | matches_prerelease | matches_prerelease_mirror_node [<sub>2<sub>](#mirror-node) | |------------------|---------------------|------------------------| ----------------------------------| | `Op::Exact` | | | | | =I.J.K | =I.J.K | >=I.J.K, <I.J.(K+1)-0 | >=I.J.K, <I.J.(K+1)-0 | | =I.J | >=I.J.0, <I.(J+1).0 | >=I.J.0, <I.(J+1).0-0 | >=I.J.0-0, <I.(J+1).0-0 | | =I | >=I.0.0, <(I+1).0.0 | >=I.0.0, <(I+1).0.0-0 | >=I.0.0-0, <(I+1).0.0-0 | | `Op::Greater` | | | | | >I.J.K | >I.J.K | >I.J.K | >I.J.K | | >I.J | >=I.(J+1).0 | >=I.(J+1).0-0 | >=I.(J+1).0-0 | | >I | >=(I+1).0.0 | >=(I+1).0.0-0 | >=(I+1).0.0-0 | | `Op::GreaterEq` | | | | | >=I.J.K | >=I.J.K | >=I.J.K | >=I.J.K | | >=I.J | >=I.J.0 | >=I.J.0 | >=I.J.0-0 | | >=I | >=I.0.0 | >=I.0.0 | >=I.0.0-0 | | `Op::Less` | | | | | <I.J.K | <I.J.K | <I.J.K or I.J.K-0 depends [<sub>1<sub>](#op-less) | <I.J.K | | <I.J | <I.J.0 | <I.J.0-0 | <I.J.0-0 | | <I | <I.0.0 | <I.0.0-0 | <I.0.0-0 | | `Op::LessEq` | | | | | <=I.J.K | <=I.J.K | <=I.J.K | <=I.J.K | | <=I.J | <I.(J+1).0 | <I.(J+1).0-0 | <I.(J+1).0-0 | | <=I | <(I+1).0.0 | <(I+1).0.0-0 | <(I+1).0.0-0 | | `Op::Tilde` | | | | | ~I.J.K | >=I.J.K, <I.(J+1).0 | >=I.J.K, <I.(J+1).0-0 | >=I.J.K, <I.(J+1).0-0 | | ~I.J | =I.J | >=I.J.0, <I.(J+1).0-0 | >=I.J.0, <I.(J+1).0-0 | | ~I | =I | >=I.0.0, <(I+1).0.0-0 | >=I.0.0, <(I+1).0.0-0 | | `Op::Caret` | | | | | ^I.J.K (for I>0) | >=I.J.K, <(I+1).0.0 | >=I.J.K, <(I+1).0.0-0 | >=I.J.K, <(I+1).0.0-0 | | ^0.J.K (for J>0) | >=0.J.K, <0.(J+1).0 | >=0.J.K, <0.(J+1).0-0 | >=0.J.K-0, <0.(J+1).0-0 | | ^0.0.K | =0.0.K | >=0.0.K, <0.0.(K+1)-0 | >=0.J.K-0, <0.(J+1).0-0 | | ^I.J | ^I.J.0 | >=I.J.0, <(I+1).0.0-0 | >=I.J.0-0, <(I+1).0.0-0 | | ^0.0 | =0.0 | >=0.0.0, <0.1.0-0 | >=0.0.0-0, <0.1.0-0 | | ^I | =I | >=I.0.0, <(I+1).0.0-0 | >=I.0.0-0, <(I+1).0.0-0 | | `Op::Wildcard` | | | | | `I.J.*` | =I.J | >=I.J.0, <I.(J+1).0-0 | >=I.J.0-0, <I.(J+1).0-0 | | `I.*` or `I.*.*` | =I | >=I.0.0, <(I+1).0.0-0 | >=I.0.0-0, <(I+1).0.0-0 | Notes: <div id="op-less"></div> - `<I.J.K`: This is equivalent to `<I.J.K-0` if no lower bound or the lower bound isn't pre-release, otherwise this is equivalent to `<I.J.K`. <div id="mirror-node"></div> - [matches_prerelease_mirror_node](dtolnay/semver@3464fd1) is yet another implementation of [node semver compatibility](https://github.com/npm/node-semver?tab=readme-ov-file#semver1----the-semantic-versioner-for-npm) (with [includePrerelease=true](https://github.com/npm/node-semver?tab=readme-ov-file#functions)) test. This is extrapolated from the test cases and is not necessarily the same as the node implementation Besides, the proposed semtantic left a [unsolved issuse ](dtolnay/semver#321 (comment)), I don't have clear idea to handle it. ### How should we test and review this PR? The tests in `src/cargo/util/semver_eval_ext.rs` are designed to reflect current semantic. ### Additional information Migrated from dtolnay/semver#321 TBO, this feature was not conceived in advance plus the semantic is unclear at first. I need to experiment step by step and find out what I think makes sense. My experiment can be seen this [comment](#13290 (comment)).
- Loading branch information