Rust Quality Gates
Before considering any change complete, all of the following must pass:
cargo build # Successful compilationcargo test # All tests passcargo clippy -- -D warnings # Zero warningscargo fmt --check # Formatting compliantDo not skip or ignore any of these checks.
Clippy Lints (library crates)
Section titled “Clippy Lints (library crates)”Deny unwrap and expect in production code, but allow them in tests:
// At crate root (lib.rs)#![cfg_attr(not(test), deny(clippy::unwrap_used, clippy::expect_used))]Using #![deny(...)] without cfg_attr will also reject .unwrap() in #[cfg(test)] modules,
causing test compilation failures.
Testing Conventions
Section titled “Testing Conventions”- Unit tests:
#[cfg(test)]module in the same file as the code under test - Integration tests:
tests/directory at crate root - Prefer trait-based fakes over
mockallunless complexity justifies it