commit:     fc409c6ed19ca0e6ad819db4a4f0070df50dc33a
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Aug  8 06:43:44 2025 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Wed Aug 13 04:58:57 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fc409c6e

install-qa-check.d/60cargo-eclass: check min verison for 'rust-version='

Another way Cargo.toml can specify the minimum Rust version is using the
'rust-version=' field. This commit adds a check for that field, and
updates the required minimum Rust version accordingly.

Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 metadata/install-qa-check.d/60cargo-eclass | 31 ++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/metadata/install-qa-check.d/60cargo-eclass 
b/metadata/install-qa-check.d/60cargo-eclass
index 743ca355de75..4fd014b2287e 100644
--- a/metadata/install-qa-check.d/60cargo-eclass
+++ b/metadata/install-qa-check.d/60cargo-eclass
@@ -7,6 +7,7 @@
 cargo_ver_check() {
        has cargo ${INHERITED} || return
 
+       local min_rust_ver= min_rust_source=
        # First version of Rust to support that edition
        declare -A RUST_EDITIONS=(
                [2024]="1.85.0"
@@ -19,14 +20,28 @@ cargo_ver_check() {
                sort -n |
                tail -n 1
        )
-       if [[ -n ${cargo_toml_edition} ]]; then
-               local min_rust_ver="${RUST_EDITIONS[${cargo_toml_edition}]}"
-               if [[ -n ${min_rust_ver} ]] && ver_test "${RUST_MIN_VER:-0}" 
-lt "${min_rust_ver}"; then
-                       eqawarn
-                       eqawarn "QA Notice: found Cargo.toml file which 
specifies edition=\"${cargo_toml_edition}\""
-                       eqawarn "which requires 
RUST_MIN_VER=\"${min_rust_ver}\""
-                       eqawarn
-               fi
+       if [[ -n ${cargo_toml_edition} && -n 
${RUST_EDITIONS[${cargo_toml_edition}]} ]]; then
+               min_rust_ver="${RUST_EDITIONS[${cargo_toml_edition}]}"
+               min_rust_source="found Cargo.toml file which specifies 
edition=\"${cargo_toml_edition}\""
+       fi
+
+       # Maximum value for "rust-version" across Cargo.toml files
+       local cargo_toml_rust_version=$(
+               find "${WORKDIR}" -name Cargo.toml -exec sed -n -e 
's/^\s*rust-version\s*=\s*"\([0-9.]*\)"\s*$/\1/p' {} \+ |
+               sort -V |
+               tail -n 1
+       )
+       if [[ -n ${cargo_toml_rust_version} ]] && ver_test "${min_rust_ver:-0}" 
-lt "${cargo_toml_rust_version}"; then
+               min_rust_ver=${cargo_toml_rust_version}
+               min_rust_source="found Cargo.toml file which specifies 
rust-version=\"${cargo_toml_rust_version}\""
+       fi
+
+
+       if [[ -n ${min_rust_ver} ]] && ver_test "${RUST_MIN_VER:-0}" -lt 
"${min_rust_ver}"; then
+               eqawarn
+               eqawarn "QA Notice: ${min_rust_source}"
+               eqawarn "which requires RUST_MIN_VER=\"${min_rust_ver}\""
+               eqawarn
        fi
 }
 

Reply via email to