| name | rust |
| description | Use when developing Rust projects in the tempoxyz org—standardizes fmt/clippy/nextest, sccache+mold, feature-powerset checks, MSRV builds, docsrs flags, and xtask patterns so local and CI behavior match. |
Rust (tempoxyz conventions)
Overview
Fast, reproducible Rust workflows aligned with tempoxyz repos: cached toolchains, mold + sccache, clippy-as-error, nextest, feature-matrix checks, docsrs parity, and xtask utilities.
Doc-first, no guessing: Always consult official docs (rust-lang.org/edition-guide, doc.rust-lang.org/std, crate docs on docs.rs). If the exact flag/API/version isn’t in docs or you’re unsure, pause and ask for the correct link instead of inferring.
When to Use
- Working on Rust crates (tempo, reth-commonware, tempo-commonware, dex-kv, tempo-std, etc.).
- Adding CI steps or local scripts to match repo expectations.
- Verifying docs/build across MSRV and nightly.
Core Pattern
Toolchain + components
- Default: stable; lint: nightly with
clippy/rustfmtwhen required. - MSRV guard: pin (e.g.,
toolchain: "1.88") and runcargo build --bin <name>.
- Default: stable; lint: nightly with
Standard commands (keep consistent with CI)
- Setup tools: install toolchains, sccache, mold, nextest, cargo-hack, typos, deny.
- Format:
cargo fmt --all --check. - Lint:
cargo clippy --all-targets --all-features --locked -- -D warnings. - Test:
cargo nextest run --no-fail-fast -j num-cpus. - Features:
cargo hack check --feature-powerset --depth 1. - Docs:
cargo doc --workspace --all-features --no-depswith docsrs flags. - MSRV: pinned-toolchain build (e.g.,
cargo +1.88 build --bin <name>).
Performance
- Use
moldlinker (rui314/setup-mold@v1or-Zshare-genericsnot needed). - Enable
sccache(mozilla-actions/sccache-action@v0.0.9); setRUSTC_WRAPPER=sccache.
- Use
Checks
- Format:
cargo fmt --all --check. - Lint:
cargo clippy --all-targets --all-features --locked -- -D warnings. - Tests:
cargo nextest run --no-fail-fast -j num-cpus(install viataiki-e/install-action@nextest). - Feature surface:
cargo hack check --feature-powerset --depth 1for broad combos. - Licenses/Deps:
cargo deny check(reuse workflow),cargo vetif present. - Typos:
typos(crate-ci/typos@v1). - Custom sanity:
zepter run check(fromtempo).
- Format:
Docs parity
cargo doc --workspace --all-features --no-deps --document-private-items.RUSTDOCFLAGS: --cfg docsrs -D warnings --show-type-layout --generate-link-to-definition --enable-index-page -Zunstable-options.
Xtask utilities
- Use existing
cargo xtaskcommands (e.g.,cargo xtask generate-genesis ...) instead of ad-hoc scripts. - Keep generated artifacts compared into repo fixtures (diff & fail if drift).
- Use existing
Env defaults
CARGO_TERM_COLOR=always,RUST_BACKTRACE=full,RUSTFLAGS="-D warnings"for builds where appropriate.
Caching
- Combine
sccachewithSwatinem/rust-cache@v2in CI; keep lockfiles pinned.
- Combine
Quick Reference
| Task | Command |
|---|---|
| Format | cargo fmt --all --check |
| Lint | cargo clippy --all-targets --all-features --locked -- -D warnings |
| Test | cargo nextest run --no-fail-fast -j num-cpus |
| Feature sweep | cargo hack check --feature-powerset --depth 1 |
| Docs | cargo doc --workspace --all-features --no-deps (+ docsrs flags) |
| MSRV | cargo build --bin tempo with pinned toolchain |
| Typos | typos |
| Zepter | zepter run check |
Common Mistakes
- Running
cargo testwithout nextest → slower/less parallel. - Skipping
--lockedcausing feature drift. - Forgetting
mold/sccache→ slow CI. - Leaving RUSTFLAGS unset → warnings slip through.
- Not updating docs when public API changes; docs job will fail in CI.
- Missing
Justfileor targets drift from CI steps → contributors can’t run parity commands locally.
Red Flags
- No clippy
-D warnings. - Feature-powerset not checked in multi-feature crates.
- MSRV not validated when adding new dependencies.
- Generated fixtures updated manually instead of via
xtask. - Docsrs flags missing; doc build passes locally but fails on docs.rs.
Verification
cargo fmt && cargo clippy ... && cargo nextest ...passes locally with sccache/mold configured.cargo hack check --feature-powerset --depth 1passes or is consciously scoped.- MSRV build succeeds on pinned toolchain.
- Docs build with docsrs flags succeeds.
Rationalizations Countered
| Excuse | Counter |
|---|---|
| "Nextest is optional" | It’s the default in CI and faster; keeps parity. |
| "mold/sccache not worth it" | Significant speedups; trivial to add. |
| "Warnings are fine" | CI treats warnings as errors; fix locally first. |
| "Feature matrix is too big" | cargo hack --depth 1 limits blast radius while catching combos. |