Rust crates rebuild for the files they read
Cargo workspaces now rebuild like Cargo does, from what the compiler and build scripts report reading instead of every file in a package:
- A crate rebuilds when a file the compiler read changes, including files
embedded with
include_str!. Editingdocs/or CI files in a package at the workspace root leaves its crate cached. - Reverting an edit reuses the build from before it, for the last eight versions of the files a crate or build script read.
- A build script reruns when a path it prints with
rerun-if-changedchanges, anywhere in the workspace. Scripts that generate code from shared protobuf definitions outside their package build without configuration, and a script no longer fails for naming an undeclared path. - A build script tool that resolves to a mise shim runs as the binary mise
selects, so build scripts that call
protocthrough mise work. struo query affected-testsattributes files a build script names in its string literals, or thatbuild_script_datadeclares, to that package, so a change to a shared.protoselects the tests of every crate that depends on the generated code.- A changed path that a target excludes, such as a file under Cargo's
targetdirectory, no longer selects every test.
Rule authors can use the same mechanism through run_action's new
input_discovery option. See the Rust guide.