chore(tooling): add project rustfmt.toml and pin the stable toolchain
What
Adds a project-level formatting policy and a toolchain pin, then applies the
formatting so the first step of the quality gate (cargo fmt --check) actually
passes.
rustfmt.toml(new) —edition = "2021",max_width = 100, plus a
comment explaining why nothing nightly-only may be added.rust-toolchain.toml(new) —channel = "stable"(the channel CI
installs) with therustfmtandclippycomponents, and notargets.- 10 source files — formatting only (39 sites).
AGENTS.md,.github/instructions/rust.instructions.md— document
both files and the stable-only rule.
Why not the global ~/.rustfmt.toml
It cannot serve as project policy, for three measured reasons:
- rustfmt auto-loads it for every file in this repo, so it was silently
in force — and it is a 79-key dump, not a deliberate project choice. required_version = "1.7.1"is a hard failure on any newer rustfmt
(error: rustfmt version (1.11.0) doesn't match the required version (1.7.1)), and no installable nightly ships rustfmt 1.7.1 — the nightlies
from 2024-12 onward are all 1.8.0+.unstable_features = falsedisables the 27 nightly-only options the same
file declares, so they never applied even on a nightly formatter.
Measured diff sites for git ls-files '*.rs':
| Config | Formatter | Diff sites |
|---|---|---|
| none (rustfmt defaults) | stable 1.10.0 | 39 |
| none (rustfmt defaults) | nightly 1.11.0 | 39 |
~/.rustfmt.toml verbatim | stable 1.10.0 | 50 |
~/.rustfmt.toml (stable subset) | nightly 1.11.0 | 101 |
~/.rustfmt.toml + use_small_heuristics = "Max" | both | 206 |
Defaults + max_width = 100 is the only combination that is both small-churn
and identical on stable and nightly — which is what makes the gate
reproducible.
Toolchain decision
Keep rust-toolchain.toml, pinning stable to match CI
(.github/workflows/ci.yml and release.yml both use
dtolnay/rust-toolchain@stable). It replaces a stray untracked local file that
pinned 1.78.0 plus targets = ["x86_64-unknown-linux-gnu"] — unusable on
this machine and too old for current dependencies. No target is pinned because
cross-compilation is driven by release.yml, not by this file.
Note for mise users: when mise provides cargo on PATH it takes precedence
over the rustup shim, so this file is not a guarantee there. That is called out
in AGENTS.md.
Gate
All six steps green (RUSTFLAGS="-C linker=/usr/bin/cc" for the linker
workaround from #77):
cargo fmt --check— clean, and also clean under nightly rustfmt 1.11.0cargo build --workspace/--features iklo-cli/turso— okcargo test --workspace(59 passed) /--features iklo-cli/turso(90 passed)cargo clippy --workspace --all-targets --features iklo-cli/turso— no new
warnings; the source diff is identical modulo whitespace (git diff -wshows
no changed non-blank lines)
Follow-ups (deliberately not in this PR)
- CI has no
cargo fmt --checkstep, so this policy is still advisory. A
3-line job inci.ymlwould enforce it. - #77 stays open: the linker/Xcode 27 issue and the
RUSTFLAGSworkaround are
untouched here.
Refs #77
Summary by cubic
Adds a project-level rustfmt policy and pins the Rust toolchain to stable so cargo fmt --check passes on every toolchain, now enforced in CI.
- New
rustfmt.tomlkeeps only options that behave identically across rustfmt releases (edition,max_width = 100); nightly-only options are banned. - New
rust-toolchain.tomlpinsstablewith therustfmtandclippycomponents, matching CI; no cross-compilation target is pinned. - CI installs the
rustfmtcomponent and runscargo fmt --check, so the policy is enforced rather than advisory (CI fixes: YAML indentation and action reference typos). - Reformats 10 source files (39 sites, whitespace-only) and documents both files in
AGENTS.mdand.github/instructions/rust.instructions.md.
Stable-only options keep the gate consistent across toolchains but don't freeze rustfmt defaults between stable releases; running the check in CI is what catches that drift.
Refs #77
Summary by Sourcery
Establish a reproducible stable Rust formatting workflow and enforce it in CI.
New Features:
- Add project-level Rust formatting and toolchain configuration aligned with the stable CI environment.
Enhancements:
- Apply the project formatting policy across the affected Rust sources.
- Document the formatting and toolchain requirements, including the stable-only rustfmt policy and mise behavior.
CI:
- Install rustfmt in CI and enforce formatting with cargo fmt --check.
Summary by CodeRabbit
- Chores
- Automated checks now verify Rust formatting before builds and tests, helping catch formatting issues earlier.
- The project’s Rust toolchain now includes formatting and linting tools.
- Documentation
- Updated development guidance explains how to format and check code, the project’s formatting conventions, and how the configured Rust toolchain affects development commands.