Skip to main content

Module rust_tools

Module rust_tools 

Source
Expand description

The three Rust hooks: cargo fmt --check, cargo clippy, cargo test.

Scoped like every other language hook — they fire only when the commit (or push) touches Rust, and only in a directory that actually has a Cargo.toml. A Python repo never invokes cargo.

Split across the two dispatchers by COST, matching what the other languages already do: fmt and clippy are pre-commit (as ruff and pyright are), test is pre-push (as run-tests-js is). Nobody wants to wait for a workspace test run on every commit.

Each is a separate check rather than one “rust” hook, so hook.skip can disable them individually — git config hook.skip clippy when you are mid-refactor, without losing the formatting gate.

Constants§

EXTS
What cargo fmt is handed. Exported so registry.rs declares the scope from the same constant — see lint_json_yaml::EXTS.
RUST_PATHS
Files that mean “this commit touches Rust”. Cargo.toml and Cargo.lock count: a dependency bump compiles differently without a single .rs edit, and that is exactly when clippy earns its keep.

Functions§

clippy
fmt
test
pre-push. Mirrors run-tests-js: the range that is actually being pushed decides whether the suite runs, so a docs-only push costs nothing.