Skip to content

Cargo check (via rust-analyzer) forcing full rebuilds. #15529

@497e0bdf29873

Description

@497e0bdf29873

Problem

I'm running into the issues described in rust-lang/rust-analyzer#17155, and first attributed to rust-analyzer, but have myself traced it down to cargo check.

Basically, cargo check seems to cause changes in file time stamps (that cargo build itself does not cause!), and this causes cargo build to fully rebuild unmodified (*-sys type) sub-crates and run build.rs, unnecessarily. This makes it pretty much impossible to run rust-analyzer.

Steps

If I edit and save a file in Zed, which runs rust-analyzer and through it, cargo check, a cargo build in the terminal will always be full (of the project and sub-crates, not of external dependencies).

If I edit the same file in a simple editor like joe, which doesn't know anything abour rust-analyzer and cargo, only the necessary components will be rebuilt by cargo build.

But I can even remove the editor out of the equation: If

  1. I run cargo check, without even touch any file,
  2. a subsequent cargo build will be a full rebuild.
  3. However, a cargo build followed by a cargo build, will do nothing.

So there's something weird going on with cargo check.

Possible Solution(s)

No response

Notes

I suspect relationship to #10175 and #15073.

Version

cargo 1.89.0-nightly (056f5f4f3 2025-05-09)
release: 1.89.0-nightly
commit-hash: 056f5f4f3c100cb36b5e9aed2d20b9ea70aae295
commit-date: 2025-05-09
host: aarch64-apple-darwin
libgit2: 1.9.0 (sys:0.20.0 vendored)
libcurl: 8.7.1 (sys:0.4.80+curl-8.12.1 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 3.4.1 11 Feb 2025
os: Mac OS 15.4.1 [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-build-scriptsArea: build.rs scriptsA-rebuild-detectionArea: rebuild detection and fingerprintingC-bugCategory: bugS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions