Subject: [PATCH rust-team 2/2] build-system: cargo: add-dependencies: Silence warning.

From: Herman Rimm <[email-masked]>
Date: Fri, 3 Jan 2025 20:40:59 +0100

* guix/build-system/cargo.scm (add-dependencies): Silence warning.

Change-Id: I8691766fc19073719e75c05eb5bfbce45ffc9b80
---
 guix/build-system/cargo.scm | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index b22b9247a1c..877ebaec135 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -34,6 +34,7 @@ (define-module (guix build-system cargo)
   #:use-module (guix platform)
   #:use-module (guix build-system)
   #:use-module (guix build-system gnu)
+  #:use-module (ice-9 format)
   #:use-module (ice-9 match)
   #:use-module (ice-9 vlist)
   #:use-module (srfi srfi-1)
@@ -51,13 +52,20 @@ (define-module (guix build-system cargo)
 (define* (add-dependencies dependencies)
   "DEPENDENCIES is a list of (crate version features).  It is formatted
 and appendended to Cargo.toml."
-  #~(let ((port (open-file "Cargo.toml" "a")))
-      (format port "
+  (let ((dependencies
+         (map (match-lambda
+                ((crate version ()) (list crate version #f))
+                ((crate version (? pair? features))
+                 (list crate version (format #f "~{~s~^,~}" features)))
+                (dep dep))
+              dependencies)))
+    #~(let ((port (open-file "Cargo.toml" "a")))
+        (format port "
 ~:{[dev-dependencies.~a]
 version = ~s
-~@[features = [~{~s~^,~}]~]~%~}"
-              '#$dependencies)
-      (close port)))
+~@[features = [~a]~]~%~}"
+                '#$dependencies)
+        (close port))))
 
 (define %crate-base-url
   (make-parameter "https://crates.io"))
-- 
2.45.2