Skip to content

Commit 5af42ef

Browse files
committed
models/version: Infer msrv attribute based on edition if rust_version is not set
1 parent a1b9583 commit 5af42ef

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

app/models/version.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ export default class Version extends Model {
2929
*/
3030
@attr rust_version;
3131

32+
/**
33+
* The Rust edition required to compile this crate version.
34+
* @type {string | null}
35+
*/
36+
@attr edition;
37+
3238
/** @type {boolean | null} */
3339
@attr has_lib;
3440
/** @type {string[] | null} */
@@ -46,8 +52,14 @@ export default class Version extends Model {
4652

4753
get msrv() {
4854
let rustVersion = this.rust_version;
49-
// add `.0` suffix if the `rust-version` field only has two version components
50-
return /^[^.]+\.[^.]+$/.test(rustVersion) ? `${rustVersion}.0` : rustVersion;
55+
if (rustVersion) {
56+
// add `.0` suffix if the `rust-version` field only has two version components
57+
return /^[^.]+\.[^.]+$/.test(rustVersion) ? `${rustVersion}.0` : rustVersion;
58+
} else if (this.edition === '2018') {
59+
return '1.31.0';
60+
} else if (this.edition === '2021') {
61+
return '1.56.0';
62+
}
5163
}
5264

5365
get isNew() {

0 commit comments

Comments
 (0)