From 5af42ef85034170b2f4ed58004d0b26172a3a9e0 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Tue, 19 Nov 2024 09:31:51 +0100 Subject: [PATCH] models/version: Infer `msrv` attribute based on `edition` if `rust_version` is not set --- app/models/version.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/models/version.js b/app/models/version.js index 87b1c29a2ec..a49ab2b9369 100644 --- a/app/models/version.js +++ b/app/models/version.js @@ -29,6 +29,12 @@ export default class Version extends Model { */ @attr rust_version; + /** + * The Rust edition required to compile this crate version. + * @type {string | null} + */ + @attr edition; + /** @type {boolean | null} */ @attr has_lib; /** @type {string[] | null} */ @@ -46,8 +52,14 @@ export default class Version extends Model { get msrv() { let rustVersion = this.rust_version; - // add `.0` suffix if the `rust-version` field only has two version components - return /^[^.]+\.[^.]+$/.test(rustVersion) ? `${rustVersion}.0` : rustVersion; + if (rustVersion) { + // add `.0` suffix if the `rust-version` field only has two version components + return /^[^.]+\.[^.]+$/.test(rustVersion) ? `${rustVersion}.0` : rustVersion; + } else if (this.edition === '2018') { + return '1.31.0'; + } else if (this.edition === '2021') { + return '1.56.0'; + } } get isNew() {