From 44b94a9276f39a653d68bd443c0aa0c3d05e471f Mon Sep 17 00:00:00 2001 From: Brennan Vincent Date: Sun, 23 Mar 2025 10:41:23 -0700 Subject: [PATCH] gnu: rust: Install stdlib manifest with original checksums. * gnu/packages/rust.scm (rust)[arguments]: Install stdlib manifest with the original checksums. Change-Id: I1100ffe4ff67c8e2026e802fc3902ec218e2efee Signed-off-by: Efraim Flashner --- gnu/packages/rust.scm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm index bf7eeb5fbf53e1de5103c9814905dd27e2a4bf8a..77441bc6237f519f6244887d8abe48971bc6e563 100644 --- a/gnu/packages/rust.scm +++ b/gnu/packages/rust.scm @@ -1475,12 +1475,29 @@ safety and thread safety guarantees.") (invoke "./x.py" "install" "clippy") (invoke "./x.py" "install" "rust-analyzer") (invoke "./x.py" "install" "rustfmt"))) + (add-before 'patch-cargo-checksums 'save-old-library-manifest + (lambda _ + (copy-file "library/Cargo.lock" ".old-library-manifest"))) (add-after 'install 'install-rust-src (lambda* (#:key outputs #:allow-other-keys) (let ((out (assoc-ref outputs "rust-src")) (dest "/lib/rustlib/src/rust")) (mkdir-p (string-append out dest)) (copy-recursively "library" (string-append out dest "/library")) + ;; rust-analyzer needs the original checksums; otherwise + ;; it fails to cargo manifest in the stdlib, and then + ;; analysis/inference involving stdlib structs doesn't work. + ;; + ;; For example, in the following trivial program: + ;; + ;; fn main() { + ;; let x = Vec::::new(); + ;; } + ;; + ;; rust-analyzer since version 1.82 can't infer + ;; the type of x unless the following line is present. + (copy-file ".old-library-manifest" + (string-append out dest "/library/Cargo.lock")) (copy-recursively "src" (string-append out dest "/src"))))) (add-before 'install 'remove-uninstall-script (lambda _