Linting & Formatting Best Practices
Low-friction, high-signal quality gates keep Rust codebases consistent without debate-driven review churn.
Search across all documentation pages
Low-friction, high-signal quality gates keep Rust codebases consistent without debate-driven review churn.
allow as technical debt with an owner.cargo fmt --all --check in CI. Zero manual style review.rustfmt.toml at workspace root with edition = "2024". Matches Cargo edition.#[rustfmt::skip] without comment. Rare FFI/layout exceptions only.cargo clippy --workspace --all-targets -- -D warnings on PRs. Tests and benches included.--all-features matrix job. Cfg-gated code linted.clippy.toml documents disallowed APIs. e.g. ban raw std::env::var in apps.[lints.clippy] for apps vs libs. Stricter unwrap_used deny in binaries.cargo clippy --fix diffs. No blind auto-fix merges.missing_docs = "warn" on published library crates. Ratchet to deny over time.RUSTDOCFLAGS="-D warnings" in doc CI job. Broken intra-doc links fail build.cargo test --doc --workspace.# Errors / # Safety sections on fallible and unsafe API. API guidelines compliance.//! docs on every lib root. crates.io and docs.rs presentation.rust-toolchain.toml pins 1.97.0 + rustfmt + clippy components. Local/CI parity.Swatinem/rust-cache or equivalent. Sub-5-minute lint jobs on warm cache.rust-version from manifest. Not only latest stable.#[allow(clippy::...)] with reason comment. No file-level blanket allows.forbid(unsafe_code) on domain crates; single FFI crate exempt. Documented in ARCHITECTURE.fmt --check + clippy -D warnings + test on stable 1.97.0.
Start with default clippy; enable pedantic on new crates if team wants stricter idioms.
Warn-level lints with ratchet; fix files touched per PR rule.
Optional preview; main gate stays on pinned stable.
Platform team or tech lead; changes via PR with team notice.
Always run cargo fmt after resolving conflicts.
Exclude from rustfmt/clippy via ignore paths; never hand-edit generated sources.
Fewer style comments in review; faster CI green rate; clippy catches in postmortems decline.
Separate job: licenses, advisories, duplicate deps - complements clippy.
Developers still get CI feedback; strongly recommend check.command = clippy in settings.
Stack versions: This page was written for Rust 1.97.0 (edition 2024), Tokio 1.x, Axum 0.8, serde 1.0, sqlx 0.8, clap 4, and Polars 0.46+.
Reviewed by Chris St. John·Last updated Jul 16, 2026