Expand description
cargo-sift — remove build artifacts from Cargo target/ directories that
the current build graph can no longer reference.
Where cargo clean deletes everything and mtime sweepers delete still-valid
artifacts, cargo sift performs a deterministic reachability GC: it
reads Cargo.lock and the workspace manifests to learn what the project
resolves to, reconstructs the build units sitting in target/, and removes
only the unreachable ones — dependency versions no longer in the lockfile,
and artifacts for removed packages and targets.
The pieces: discovery finds target dirs, resolve computes the live
set from Cargo.lock (no cargo subprocess), units reconstructs units
from disk, and gc classifies and removes them.
Modules§
- cli
- Command-line surface for
cargo-sift. - discovery
- Locating real Cargo target directories.
- gc
- The garbage collector: classify every unit in
target/against the current resolve, then remove what’s unreachable. Fully deterministic — no file timestamps are consulted. - human
- Human-readable size formatting.
- resolve
- The current resolve, computed without invoking cargo — parsed from
Cargo.lockand the workspace manifests. - units
- Reconstructing cargo’s build units from the contents of
target/.
Functions§
- run
- Entry point shared by the binary: resolve target directories, then GC each one against its own current resolve.