# Rust Engineering Standard

**Version 1.0 · 30 November 2026**

> **Superseded (notice added 30 November 2026).** Version 1.1 replaces this version. Use the latest version at `https://fitchhub.com/standards/rust.md`. This page keeps the v1.0 text unchanged as a record. Corrections ship only in newer versions.
>
> **Known errors in v1.0** (each corrected in v1.1):
>
> - **Appendix A.1, `clippy::lossy_float_literal`:** The baseline enables this lint even though Clippy 0.1.100 flags exact IEEE-754 powers of two such as `2_147_483_648.0_f32`. Its suggested replacement, `2_147_483_600.0`, is inexact and silently changes the value ([rust-lang/rust-clippy#7404](https://github.com/rust-lang/rust-clippy/issues/7404)).
> - **Appendix A.1, `clippy::collection_is_never_read`:** The baseline enables this nursery lint even though it flags collections that keep resources alive. Removing a collection of `Arc` handles held across an FFI `poll` call can introduce a use-after-free or premature-close race.
> - **Appendix A.1, wholesale `clippy::pedantic`:** The group enables `clippy::invalid_upcast_comparisons`, which falsely reports narrowing, wrapping casts such as `(hr as i32) < 0` for `hr: u64` as "always false" in Clippy 0.1.100 ([rust-lang/rust-clippy#7648](https://github.com/rust-lang/rust-clippy/issues/7648)). The group also enables noisy style and FFI lints: `borrow_as_ptr`, `used_underscore_items`, `many_single_char_names`, `unreadable_literal`, `default_trait_access`, `semicolon_if_nothing_returned`, `single_match_else`, and `ignored_unit_patterns`.
> - **Section 5.3 and Appendix A.3, `excessive-nesting-threshold = 4`:** `clippy::excessive_nesting` counts `mod`, `impl`, and `fn` blocks. A threshold of `4` flags a single `for` loop with one `if` inside an inline `mod` and `impl`.
> - **Section 5.3, `allow-*-in-tests` recognition:** Clippy 0.1.100 recognizes bare `#[cfg(test)]` modules but misses `#[cfg(all(test, ...))]` modules. Stacking `#[cfg(test)]` and `#[cfg(...)]` restores the test allowances.
> - **Appendix A.4, `use_try_shorthand = true`:** This rustfmt option targets the deprecated Rust 2015 `try!()` macro and is obsolete in an Edition 2024 standard.

- **Canonical agent-readable Markdown (always the latest version):** `https://fitchhub.com/standards/rust.md`
- **Pinned release Markdown (this version only):** `https://fitchhub.com/standards/rust/v1.0.md`

This standard governs Rust workspace design, linting, formatting, dependency policy, and verification. It applies to agents adopting or updating these checks and to engineers reviewing their work.

**Apply strict checks by default.** Relax an applicable check only when the best reasonable compliant implementation harms a supported contract or adds disproportionate complexity without a meaningful safety or correctness benefit.

**Treat the baseline as a floor, not a ceiling.** Keep stronger local checks that work. Show the user driving the work where those checks add value so they can be considered for this standard.

**Quality-tool versions are minimums, never pins or ceilings.** Use current releases for the quality job, with Rust 1.100.1 or later. A repository can pin the selected toolchain for reproducibility. A library's `package.rust-version` makes a separate compatibility promise to its consumers.

**Raise regressions directly to the user driving the work.** Present concrete evidence before weakening a requirement or adding a workaround. A green build is necessary for acceptance; it does not establish that behavior is correct.

This document is self-contained. Each adopting repository supplies its own manifests, target and feature mappings, acceptance commands, and local exception records. No prior releases or external conversations are required to interpret or apply it.

## Contents

1. [Quality, current-date grounding, and authority](#1-quality-current-date-grounding-and-authority)
2. [Quality exceptions](#2-quality-exceptions)
3. [Code design and behavioral contracts](#3-code-design-and-behavioral-contracts)
4. [Workspace coverage, editions, and toolchains](#4-workspace-coverage-editions-and-toolchains)
5. [Compiler, Cargo, and Clippy requirements](#5-compiler-cargo-and-clippy-requirements)
6. [Composable profiles](#6-composable-profiles)
7. [Formatting, dependencies, and artifacts](#7-formatting-dependencies-and-artifacts)
8. [Verification and enforcement integrity](#8-verification-and-enforcement-integrity)
9. [Adoption, upgrades, and escalation](#9-adoption-upgrades-and-escalation)
10. [Acceptance and maintenance](#10-acceptance-and-maintenance)

- [Appendix A: Starter configurations](#appendix-a-starter-configurations)
- [Appendix B: Repository records](#appendix-b-repository-records)
- [Appendix C: Changelog](#appendix-c-changelog)
- [References](#references)

## 1. Quality, current-date grounding, and authority

### 1.1 Quality criteria

| Criterion       | Required outcome                                                                              |
| --------------- | --------------------------------------------------------------------------------------------- |
| Correctness     | Supported inputs, failures, and state transitions preserve the public contract.               |
| Maintainability | Each invariant has an owner. Changing it does not require finding undocumented copies.        |
| Readability     | Names, types, and control flow explain who owns data and where an operation can fail.         |
| Consistency     | Equivalent operations use the same contracts for errors, resource ownership, and persistence. |
| Reuse           | Consumers share the authoritative type or operation without depending on unrelated policy.    |
| Efficiency      | Allocations, copies, locks, and scheduling costs fit the measured workload.                   |

### 1.2 Current-date, native-first engineering

Inspect the installed tools before proposing wrappers or custom lint engines. Use `rustc -W help`, `cargo clippy --explain <lint>`, `rustfmt --help=config`, and `rustdoc -W help`. Check the installed crate source and documentation for the version in `Cargo.lock`. Reproduce surprising behavior with the repository's actual target and features.

Prefer Edition 2024 and stable Rust 1.100 facilities when the crate's supported compilers provide them. Use `[lints.cargo]` for manifest checks, `CARGO_BUILD_WARNINGS=deny` for acceptance, and `#[expect(..., reason = "...")]` for reviewed exceptions. Consider `core::mem::DropGuard` for rollback, the stabilized never type (`!`) for an impossible result, and `std::mem::conjure_zst` for a zero-sized value under its documented safety contract. In `clippy.toml`, a `disallowed-methods` entry can name the approved alternative with `replacement = "..."`.

The quality job must run Rust `>= 1.100.1`. Read `rust-toolchain.toml` to identify the selected compiler. Read each package's `rust-version` to identify its minimum supported Rust version (MSRV). Do not adopt a new API in a library until its actual MSRV supports that API.

### 1.3 Requirements, discretion, and escalation

**Must** identifies a requirement. **Should** identifies a recommendation for the stated context. **May** identifies a permitted choice. Apply the baseline and compose the profiles that describe the code. Mapping an embedded crate to its target triple or a CLI to its output stream preserves enforcement; neither requires an exception.

Disabling a check, raising a limit, or excluding supported code reduces coverage regardless of whether the change lives in a manifest, attribute, script, or CI job. A relaxation beyond a defined profile requires Section 2. Adoption alone does not authorize merging, deploying, altering product contracts, or overwriting unrelated work. Escalate regressions under Section 9.4 and preserve effective stronger checks under Section 9.5.

## 2. Quality exceptions

### 2.1 Eligibility

Compare realistic alternatives, including a straightforward compliant implementation. An exception is eligible only if that implementation would harm a supported contract (including safety, compatibility, or measured performance), or add disproportionate complexity without a meaningful safety or correctness benefit. A deadline, a long diagnostic list, and a preference for the old code do not qualify.

### 2.2 Decision process

1. **Finding.** Record the toolchain versions, lint, settings, target, features, location, and reproducing command. Consult `cargo clippy --explain <lint>` for a Clippy finding.
2. **Contract.** Name the affected caller, invariant, resource lifetime, or supported platform.
3. **Comparison.** Show the best compliant implementation and the proposed exception. Identify the concrete cost or regression.
4. **Narrowest adjustment.** Limit the change to the item, target, or feature that needs it. Keep other lint levels intact.
5. **Remaining protection.** Identify the type, boundary check, behavioral test, or other evidence that protects the contract.
6. **Review record.** Complete the Appendix B record, assign a `QX-*` identifier, and name the condition for removal.

### 2.3 Structural, panic, and unsafe exception evidence

For `cognitive_complexity`, `excessive_nesting`, or `too_many_arguments`, show the actual decision structure or signature. Compare a cohesive extraction. Identify the shared borrow, ordering constraint, or ABI the extraction would obscure or break. Line count alone does not establish harm.

For panic, unwrap, and indexing exceptions, prove the invariant in the types or at the input boundary. Explain why it still holds at the operation. A passing example does not prove an index is always in range or a string offset is always a character boundary.

For `unsafe`, account for aliasing, provenance, alignment, lifetime, initialization, ABI, and thread safety where applicable. Link each obligation to the caller precondition or implementation that establishes it. A `// SAFETY:` comment is evidence to audit, not proof of soundness.

### 2.4 Scope, attributes, and automated suppression enforcement

Prefer an item-level `#[expect(clippy::too_many_arguments, reason = "QX-001: matches the registered callback signature")]`. If a diagnostic fires only for one target or feature, make its expectation conditional too. For example, `#[cfg_attr(target_pointer_width = "64", expect(clippy::cast_possible_truncation, reason = "QX-002: validated the offset at the protocol boundary"))]` avoids an unfulfilled expectation on other pointer widths. Match the condition to the observed diagnostic. Give each code exception a concrete removal condition, not a quota or a calendar expiration date. Advisory ignores in cargo-deny use `expiry` instead (Section 7.2).

Reserve `#[allow(..., reason = "QX-...")]` for configuration-dependent diagnostics that cannot consistently fulfill a conditional expectation, or genuine module or crate exemptions. An FFI crate or generated binding module can use an inner `#![allow(unsafe_code, reason = "QX-003: audited ABI boundary")]`. Do not use `#![allow(warnings)]`, `#[allow(clippy::all)]`, `#[allow(clippy::pedantic)]`, `#[allow(clippy::restriction)]`, undocumented suppressions, or scaffold clusters such as `#[allow(dead_code, unused_imports, unused_variables)]`.

| Native check                              | Coverage in Clippy 0.1.100 and Cargo 1.100                                                                                                                                                                     |
| ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `clippy::allow_attributes`                | Flags outer `#[allow]` in favor of `#[expect]`. Intentionally skips inner `#![allow]`.                                                                                                                         |
| `clippy::allow_attributes_without_reason` | Checks outer and inner `allow` and `expect` for a missing `reason`. Does not validate the reason text or `QX-*` format. Both attribute lints respect the configured MSRV (1.81 or later for this enforcement). |
| `unfulfilled_lint_expectations`           | Flags a stale `#[expect]` when the checker runs but the expected finding no longer occurs.                                                                                                                     |
| `cargo::missing_lints_inheritance`        | Warns when a member omits `[lints]`. Accepts an empty table or an independent lint configuration.                                                                                                              |

If the repository requires mechanical enforcement beyond this coverage, use a workspace policy test or an `xtask`. Query `cargo metadata --no-deps --format-version 1`, follow `workspace_members` to each participating manifest, and require `[lints] workspace = true` unless Appendix B exempts that member. Parse checked-in member `.rs` files with `syn`. Inspect outer, inner, and `cfg_attr`-wrapped `allow` and `expect` attributes for banned blanket targets and reasons matching `^QX-[A-Z0-9-]+:\s+\S`. Explicitly permit the documented Section 6.2 CLI output mapping if the repository uses it; do not require a `QX-*` exception for that mapping. Source syntax inspection covers checked-in attributes, not attributes produced by macro expansion. `dylint` is an option for compiler-aware custom diagnostics; its nightly and `rustc-dev` coupling buys little for text and manifest policy.

### 2.5 Non-negotiable boundaries

- Preserve checker exit codes and diagnostics. Do not filter findings or silently drop `[lints] workspace = true`.
- Do not turn recoverable failures into `.unwrap()` or `panic!()`, or discard them with a silent `if let Ok(_)` or `let _ =`.
- Do not fabricate an `unsafe impl Send` or `unsafe impl Sync` to satisfy an executor.
- Do not hide production code behind `#[cfg(not(test))]` to bypass verification.
- Do not weaken assertions, delete a failing case, or replace the real boundary with a mock that implements the expected result.

## 3. Code design and behavioral contracts

### 3.1 Shared contracts, types, and reuse

Give each domain contract one authoritative crate or module. Use a newtype for a validated identifier, and an enum when only named states are valid. Share the parser and type across callers rather than interpreting raw strings or integers independently.

Libraries should expose typed error enums, for example with `thiserror`. Applications and CLIs may aggregate failures with `anyhow` at their outer boundary. Do not expose `Result<T, String>`, `Result<T, ()>`, or `Box<dyn Error>` in public library APIs unless an external trait contract requires it. Implement `Default` only when the value represents a valid initial state.

### 3.2 Ownership, borrowing, fallibility, and conversions

Accept `&str`, `&[T]`, or `&Path` when a function needs only a view. Justify a deep `.clone()` by the distinct owner that needs the copy. Use `Arc::clone(&x)` and `Rc::clone(&x)` for reference-count increments (`clone_on_ref_ptr`). Introduce `Arc<Mutex<T>>` for an actual shared mutation contract, not to silence the borrow checker. Do not manufacture a `'static` lifetime with `Box::leak`.

Keep production paths panic-free. Propagate fallible work with `?`; use `.get()`, `.first()`, iterators, or slice patterns to handle missing elements. For UTF-8, use `.get(..n)`, checked character boundaries, or character iterators instead of `&s[..n]`. Prefer `From` for lossless conversions and `TryFrom` for checked conversions. Choose checked or saturating arithmetic according to the domain rather than hiding overflow with `as`.

Retain underlying errors with `#[source]`, `#[from]`, or `.context(...)`. Do not erase the cause with `.map_err(|_| ...)` or discard the outcome with `.ok();` or `let _ = fallible();`. Use RAII (`Drop`) or `core::mem::DropGuard` for transactional rollback so `?` and early returns run the same cleanup.

### 3.3 Behavioral preservation and banned compliance shims

| Contract                    | Preserve when changing code to satisfy a check                                                     |
| --------------------------- | -------------------------------------------------------------------------------------------------- |
| Errors and panics           | Error variants, cause chains, exit status, and recovery at fallible boundaries.                    |
| Data and serialization      | Wire names, representations, numeric ranges, UTF-8 boundaries, and compatibility with stored data. |
| Ownership, drops, and state | Borrow duration, destruction order, cleanup, and visibility of committed state.                    |
| Concurrency and async       | Lock ordering, cancellation, backpressure, task completion, and ordering guarantees.               |
| `unsafe`, ABI, and FFI      | Layout, calling convention, pointer validity, ownership transfer, and unwind boundaries.           |
| Distribution and features   | Public API, MSRV, published dependencies, supported feature sets, and target triples.              |

Do not replace an unwrap with a silent `if let Ok(...)`, keep scaffolding with `let _ = x;` or `#[allow(dead_code)]`, or derive a bogus `Default`. Do not invent a parameter bag or split a function solely to pass a threshold. Do not dodge a cast diagnostic with `std::mem::transmute`. `todo!()` and `unimplemented!()` are not finished behavior; `#[cfg(not(test))]` is not a fix for a failing test.

### 3.4 Decomposition and module boundaries

Split responsibilities at a contract a caller can understand independently. Keep a cohesive match or state transition together when extraction would scatter its invariants. Start private and use `pub(crate)` when the workspace code inside that crate needs access. Use `unreachable_pub` throughout the workspace and `dead_code_pub_in_binary` in binary crate roots only. Match owned enum variants explicitly: without a `_ =>` arm, adding a variant makes the compiler identify each consumer that needs review.

### 3.5 Practices to correct

| Finding in the adoption scope                                | Correction                                                                             |
| ------------------------------------------------------------ | -------------------------------------------------------------------------------------- |
| A parser returns a string that every caller validates again. | Return a validated domain type and a typed parse error.                                |
| An extra clone ends a borrow conflict.                       | Inspect who needs ownership; split the borrow or move the value at its last use.       |
| A mutex serializes independent work.                         | Give the state one owner or borrow disjoint fields before introducing synchronization. |
| A placeholder match arm returns success.                     | Handle the variant or return an error the caller can act on.                           |
| An error message contains a formatted cause but no source.   | Wrap the original error so callers can inspect or report the chain.                    |
| A helper exists only to move a warning.                      | Restore the cohesive operation and resolve the underlying finding.                     |

## 4. Workspace coverage, editions, and toolchains

### 4.1 Source, target, and feature coverage matrix

| Code or configuration                       | Required coverage                                                                                                                                                                                             |
| ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Library, binaries, tests, benches, examples | `--workspace --all-targets` checks these Cargo target kinds for **one selected target triple**. Add jobs for other supported operating systems and architectures. Cross-compilation is not an execution test. |
| Features                                    | Check the default build, supported no-default builds, and supported combinations. Use `--all-features` only when the features coexist.                                                                        |
| Documentation examples                      | Run doctests separately when using nextest. Verify the feature and target assumptions in examples.                                                                                                            |
| `build.rs`                                  | Declare inputs with `cargo::rerun-if-changed=...`. Require deterministic output and zero network calls.                                                                                                       |
| Proc macros                                 | Check the host-built macro crate and exercise its expansions in consuming crates on the supported targets.                                                                                                    |
| Generated, vendored, and patched code       | Record origin, version or revision, owner, and freshness check. Test the real generated output or resolved `[patch.crates-io]` path.                                                                          |

### 4.2 Edition 2024, resolver 3, and toolchain pin vs MSRV

Default to `edition = "2024"`. Set `[workspace] resolver = "3"` explicitly in a virtual workspace: the members' edition does not select the virtual workspace's resolver. For private packages, inherit `[workspace.package] publish = false` with `publish.workspace = true`.

`rust-toolchain.toml` pins the compiler developers and the quality job run. `package.rust-version` declares the oldest compiler the package supports. Resolver 3 defaults `resolver.incompatible-rust-versions` to `"fallback"` and prefers MSRV-compatible dependencies. That preference does not prove the crate builds. Compile and test a library with the actual compiler it promises to support, separately from the current quality job. Do not pass the quality job's `CARGO_BUILD_WARNINGS=deny` to an older-MSRV compatibility build.

### 4.3 Workspace lint inheritance

`[workspace.lints.*]` has no effect on a member until its manifest declares `[lints] workspace = true`. Cargo rejects local lint keys alongside `workspace = true` in the same package lint table. Apply a profile through scoped crate or module attributes or a targeted quality command; do not detach a member to customize it.

`cargo::missing_lints_inheritance` detects a missing table, not an empty or independent one. Inspect each participating manifest or use the Section 2.4 workspace policy check.

## 5. Compiler, Cargo, and Clippy requirements

### 5.1 Toolchain version floors and warning enforcement

These minimum versions were verified on 30 November 2026. Install current releases, inspect changes in defaults and schemas, and record the selected versions. An optional tool's floor applies when the repository uses it.

| Tool                              | Minimum for the quality job | Basis                                                                                                                       |
| --------------------------------- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| `rustc`, `cargo`                  | `>= 1.100.1`                | 1.100.0 stabilized `[lints.cargo]`; 1.100.1 fixed a `const Iterator` inference regression. Use the corresponding `rustdoc`. |
| Clippy                            | `>= 0.1.100`                | Bundled with the supported Rust toolchain.                                                                                  |
| rustfmt                           | `>= 1.11.0`                 | Stable formatter bundled with the supported Rust toolchain.                                                                 |
| cargo-deny                        | `>= 0.22.2`                 | 0.22.1 fixed multi-version unsound and unmaintained advisory handling. Building from source requires Rust 1.95 or later.    |
| cargo-nextest (conditional)       | `>= 0.9.152`                | Includes the 0.9.150 security floor.                                                                                        |
| cargo-shear (optional)            | `>= 1.14.1`                 | Additional dependency-use checks, including development dependencies.                                                       |
| cargo-hack (conditional)          | `>= 0.6.46`                 | Feature-combination coverage.                                                                                               |
| cargo-semver-checks (conditional) | `>= 0.51.0`                 | Public API comparison; requires Rust 1.93 or later.                                                                         |
| cargo-audit (optional)            | `>= 0.23.0`                 | Lockfile and auditable binary scans.                                                                                        |

In the current quality job (Rust `>= 1.100.1`), use `CARGO_BUILD_WARNINGS=deny` for `cargo clippy`, `cargo check`, `cargo test`, and `cargo doc`. Cargo 1.97 stabilized this setting; its config equivalent is `[build] warnings = "deny"`. Keep the setting scoped to the quality job. Cargo 1.97–1.99 warns that `lints.cargo` is an unused manifest key. Denying that warning would fail an older-MSRV compatibility build even when the library compiles and passes its tests.

1. It denies local-package lint warnings from rustc, Clippy, rustdoc, and Cargo's manifest lints. `cargo clippy -- -D warnings` can exit `0` on a `cargo::*` manifest warning because the trailing flags go to the compiler.
2. It reuses Cargo's artifact cache without re-keying dependency builds. Global `RUSTFLAGS="-D warnings"` changes compile-unit identity, including dependencies, and reaches host build scripts and proc macros unless `--target` is passed.
3. Ordinary recommendations can remain `"warn"` in local development and still fail acceptance. Keep hard invariants at `"deny"` even locally: `clippy::correctness`, `unsafe_code`, `unsafe_op_in_unsafe_fn`, `unused_must_use`, `non_ascii_idents`, `clippy::let_underscore_must_use`, and `clippy::undocumented_unsafe_blocks`.

For compact agent diagnostics, use `--message-format=short`. Switch to `--message-format=human` for spans and help, or `--message-format=json` for a structured consumer. Cargo has no `--message-format=agent`.

In rust-analyzer, set `"rust-analyzer.check.command": "clippy"`. `rust-analyzer.check.allTargets` inherits `cargo.allTargets`, which defaults to `true`. Editor feedback neither replaces the acceptance job nor ensures that member manifests inherit workspace lints.

### 5.2 Base lint configuration and priority rules

Start with [Appendix A](#appendix-a-starter-configurations). Never write `all = { level = "warn", priority = -1 }`. In Clippy 0.1.100, `clippy::all` aliases `clippy::default`: 67 deny-by-default `correctness` lints and 428 warn-by-default `suspicious`, `complexity`, `perf`, and `style` lints. Setting all 495 to `warn` downgrades every correctness lint.

Keep `correctness = { level = "deny", priority = -1 }`. Give `suspicious`, `complexity`, `perf`, `style`, and `pedantic` the same priority with level `warn`. Individual lint settings default to priority `0` and take precedence. `clippy::lint_groups_priority` denies ambiguous group priority by default.

Never enable `clippy::restriction` or `clippy::nursery` wholesale. Restriction includes conflicting requirements (`clippy::blanket_clippy_restriction_lints`); nursery findings can have unstable false positives. Select individual lints with a demonstrated use.

Check stability before adding lints. In rustc 1.100.1, `rustc -W help` lists 14 unstable lints: eight allow-by-default, two warn-by-default, and four deny-by-default. The allow-by-default lints include `must_not_suspend`, `implicit_provenance_casts`, `non_exhaustive_omitted_patterns`, and `unqualified_local_imports`. Likewise, `rustdoc -W help` lists `rustdoc::missing_doc_code_examples`. Listing a lint does not make it usable on stable: naming these can trigger `unknown_lints`. Test the setting on the actual stable compiler. Use underscore names in `Cargo.toml`; Cargo 1.99 and later warn on hyphenated lint names.

### 5.3 Structural thresholds and test allowances

| `clippy.toml` setting            | Value                | Application                                                                                                                                                 |
| -------------------------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `cognitive-complexity-threshold` | `20`                 | Inspect branches and nested decisions before extracting code.                                                                                               |
| `excessive-nesting-threshold`    | `4`                  | Set a positive threshold: the Clippy default of `0` leaves `excessive_nesting` inert.                                                                       |
| `max-fn-params-bools`            | `1`                  | Replace ambiguous flags with a domain enum when callers must distinguish modes.                                                                             |
| `too-many-arguments-threshold`   | `7` (Clippy default) | Separate borrows and FFI signatures can require distinct parameters. Do not import TypeScript's limit of five or merge independent borrows to pass a check. |

| `clippy.toml` test setting        | Value   | Effect in recognized test code                                         |
| --------------------------------- | ------- | ---------------------------------------------------------------------- |
| `allow-unwrap-in-tests`           | `true`  | Allow a test to fail on a missing value.                               |
| `allow-expect-in-tests`           | `true`  | Allow a failure message with test context.                             |
| `allow-indexing-slicing-in-tests` | `true`  | Allow direct fixture access. The key is not `allow-indexing-in-tests`. |
| `allow-panic-in-tests`            | `true`  | Allow explicit failure on an unexpected test path.                     |
| `allow-print-in-tests`            | `true`  | Allow captured test output.                                            |
| `allow-dbg-in-tests`              | `false` | Catch leftover debugging probes in tests too.                          |

`allow-indexing-slicing-in-tests = true` does not exempt `clippy::string_slice`. Even in tests, use `.get(..n)` or character-boundary APIs instead of `&s[..n]` on a string.

Clippy 0.1.100 recognizes `#[test]` functions, `#[cfg(test)]` modules, and compiler input paths starting with `tests/`. In a multi-crate workspace, `crates/<member>/tests/*.rs` does **not** start with `tests/`. The test functions get the allowances, but ordinary helpers beside them or in `tests/common/mod.rs` can still trigger `unwrap_used` and `indexing_slicing`. Return `Result` from helpers and use `?` in `#[test] fn ...() -> Result<...>`. If a helper genuinely requires test-only panics, put it in a `#[cfg(test)]` module.

### 5.4 Deliberate baseline choices

| Setting or omission                                                                                             | Reason and remaining protection                                                                                                                                                                                                                                                                              |
| --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `correctness = "deny"`                                                                                          | Preserve deny-by-default findings during local iteration. Never set `all = "warn"`.                                                                                                                                                                                                                          |
| `unsafe_code = "deny"`                                                                                          | Reject accidental unsafe code. Unlike `forbid`, `deny` permits a reviewed, scoped Section 6.3 or `QX-*` opt-in.                                                                                                                                                                                              |
| `too_many_lines = "allow"`                                                                                      | A long match can be one cohesive operation. Use `cognitive_complexity` and `excessive_nesting` to review decision structure.                                                                                                                                                                                 |
| `must_use_candidate`, `return_self_not_must_use` = `"allow"`                                                    | Mechanical annotation produces thousands of low-value findings in large APIs. Mark domain constructors, guards, and results `#[must_use]` when discarding them violates intent.                                                                                                                              |
| `missing_errors_doc`, `missing_panics_doc`, `doc_markdown` = `"allow"`                                          | Require public documentation in the library profile rather than impose documentation-format churn on internal application code.                                                                                                                                                                              |
| `similar_names = "allow"`                                                                                       | Related terms such as source and destination coordinates should retain their domain names.                                                                                                                                                                                                                   |
| `implicit_hasher = "allow"`                                                                                     | Generalizing a hasher adds type parameters where the caller has no need to select one.                                                                                                                                                                                                                       |
| `map_unwrap_or = "allow"`                                                                                       | Keep the transformation and fallback separate when that makes evaluation and ownership clearer.                                                                                                                                                                                                              |
| `if_not_else = "allow"`                                                                                         | Keep the exceptional branch or common path first according to the operation.                                                                                                                                                                                                                                 |
| `struct_excessive_bools = "allow"`                                                                              | Independent protocol flags can be valid. Use enums when states are mutually exclusive.                                                                                                                                                                                                                       |
| `assigning_clones = "allow"`                                                                                    | Prefer `clone_from` when allocation reuse matters; do not require a rewrite without that benefit.                                                                                                                                                                                                            |
| `items_after_statements = "allow"`                                                                              | Permit a local item near its use without forcing unrelated definitions to the top.                                                                                                                                                                                                                           |
| Omit `wildcard_enum_match_arm` globally                                                                         | It also flags `_ =>` on external `#[non_exhaustive]` enums such as `std::io::ErrorKind`, suggesting lists of 40 or more variants. Omit wildcards on owned enums and review exhaustiveness there.                                                                                                             |
| Omit `panic_in_result_fn`                                                                                       | It rejects `assert_eq!` in `#[test] fn() -> Result<...>` even with `allow-panic-in-tests = true`. Use `panic` with the test profile.                                                                                                                                                                         |
| Omit `unwrap_in_result`                                                                                         | Narrower than `unwrap_used`: it misses `Option::unwrap()` inside a `Result` function. Use `unwrap_used` and `expect_used` across production paths.                                                                                                                                                           |
| Omit `tests_outside_test_module`                                                                                | It flags workspace integration tests under `crates/<member>/tests/*.rs` despite their dedicated integration-test targets.                                                                                                                                                                                    |
| Omit rustc's `unused_crate_dependencies` workspace-wide                                                         | It reports unused dependencies across lib, bin, and test targets of the same package. Use `cargo::unused_dependencies` and optional cargo-shear.                                                                                                                                                             |
| Keep `cast_lossless`, `cast_possible_truncation`, `cast_possible_wrap`, `cast_precision_loss`, `cast_sign_loss` | Pedantic cast checks expose silent range, precision, and sign changes. Use Section 6.3 for proven register, graphics, or pixel conversions.                                                                                                                                                                  |
| Omit `dead_code_pub_in_binary` workspace-wide                                                                   | Cargo builds library unit tests as executables. The lint then flags public library items unused by the test harness and breaks warning-denying Clippy, test, and nextest runs. Enable it only in binary crate roots (Section 6.2; [rust-lang/rust#159078](https://github.com/rust-lang/rust/issues/159078)). |
| Omit `get_unwrap`                                                                                               | Its automatic fix changes `*v.get(1).unwrap()` to `v[1]`, which violates `indexing_slicing`. `unwrap_used` already catches the production unwrap; `allow-unwrap-in-tests` exempts both lints in recognized tests.                                                                                            |
| Omit `error_impl_error`                                                                                         | `Error` is an idiomatic public type name, as in `std::io::Error`, `serde_json::Error`, and `syn::Error`.                                                                                                                                                                                                     |
| Omit `empty_structs_with_brackets`                                                                              | Changing `pub struct Marker {}` to `pub struct Marker;` introduces a public constant in the value namespace and can break consumers.                                                                                                                                                                         |
| Omit `str_to_string`                                                                                            | Choosing between `to_string()` and `to_owned()` on `str` is a style preference with no safety or performance benefit.                                                                                                                                                                                        |
| Omit obsolete overrides                                                                                         | `module_name_repetitions` moved to `restriction` in Rust 1.84. Rust 1.91 removed `string_to_string`; `implicit_clone` covers the case. `str_to_string` remains a restriction lint.                                                                                                                           |

### 5.5 Common native-lint traps and idiomatic resolutions

| Finding                                                        | Resolution                                                                                                                             |
| -------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `unnecessary_safety_comment` finds `SAFETY:` in a doc comment. | Document caller obligations under `# Safety`. Put `// SAFETY:` immediately at the unsafe operation whose preconditions it establishes. |
| `clippy.toml` repeats `msrv`.                                  | Use `package.rust-version` as the source of truth rather than let two versions drift.                                                  |
| An inner `#![allow]` passes `allow_attributes`.                | Check the reason with `allow_attributes_without_reason`; use Section 2.4 for mechanical blanket and reason-format checks.              |
| `cargo::unused_dependencies` misses dependencies.              | It skips `[dev-dependencies]` and single-target `--bin` runs. Check the whole workspace; use cargo-shear for additional coverage.      |
| `let _ = guard;` obscures a resource's lifetime.               | Bind a named guard for the required scope. Use `drop(guard)` at an intentional release point.                                          |
| `map_err_ignore` finds a discarded cause.                      | Store the underlying error as a source or attach context. A new string is not an error chain.                                          |
| An expectation for `clippy::...` passes `cargo check`.         | `cargo check` does not run Clippy. Run `cargo clippy` on the relevant target and features to check the expectation.                    |
| cargo-deny rejects a wildcard path dependency.                 | `allow-wildcard-paths = true` applies to `publish = false` crates. Publishable crates need an actual version requirement.              |

### 5.6 Project-specific architectural bans (`clippy.toml`)

Use `disallowed-methods`, `disallowed-types`, `disallowed-macros`, or `disallowed-fields` for a repository-owned boundary. Specify a fully qualified `path`, give the contract in `reason`, and name the alternative in `replacement`. List concrete APIs, not a wildcard such as `std::fs::*`. Use entries only where the dependency and the replacement are present.

Example additions for a Tokio worker that owns a filesystem interface and requires bounded queues:

```toml
disallowed-methods = [
  { path = "std::mem::transmute", reason = "Use the checked representation conversion for this wire type" },
  { path = "std::thread::sleep", reason = "Do not block a worker thread", replacement = "tokio::time::sleep" },
  { path = "tokio::sync::mpsc::unbounded_channel", reason = "The queue must apply backpressure", replacement = "tokio::sync::mpsc::channel" },
  { path = "std::fs::read", reason = "Read through the worker's filesystem interface" },
]
disallowed-types = [
  { path = "tokio::sync::mpsc::UnboundedSender", reason = "Bound producer memory", replacement = "tokio::sync::mpsc::Sender" },
]
```

## 6. Composable profiles

### 6.1 Library crates

Enable the public API checks in the library crate root (`src/lib.rs`):

```rust
#![warn(missing_docs, missing_debug_implementations)]
#![warn(
    clippy::missing_errors_doc,
    clippy::missing_panics_doc,
    clippy::doc_markdown
)]
#![warn(rustdoc::missing_crate_level_docs, rustdoc::unescaped_backticks)]
```

Describe failures in terms of what the caller can do. Use typed error enums (`thiserror`) and minimize dependency features; never depend on Tokio's `"full"` feature in a library. For publishable internal dependencies, specify both `version` and `path` so the published manifest resolves at the registry.

Build docs with `CARGO_BUILD_WARNINGS=deny cargo doc --workspace --locked --no-deps`. Compile and test on the actual compiler named by `rust-version`, without inheriting the current quality job's warning policy when testing an older MSRV. Use `cargo hack --each-feature check` for individual features or `cargo hack --feature-powerset check` for supported combinations; exclude genuinely incompatible sets explicitly. `--no-dev-deps` can temporarily rewrite manifests and change the resolved lockfile. Run that check in isolation; do not treat it as proof of a locked build or commit incidental lockfile changes. Use `cargo-semver-checks >= 0.51.0` against the supported published baseline for public API changes.

### 6.2 Application and CLI binaries

Return `std::process::ExitCode` or `anyhow::Result<()>` from `main` to report failures; `clippy::exit` flags calls to `std::process::exit`. Keep stdout for the command's result and stderr for diagnostics. Use `writeln!(io::stdout().lock(), ...)` and handle write failures. An explicit write needs no `allow(clippy::print_stdout)`. Mapping `print_stdout` or `print_stderr` to a CLI crate's intentional output boundary is an implementation mapping, not a Section 2 exception. Use `tracing` for structured diagnostics.

Enable the binary-specific visibility check in the binary crate root (for example, `src/main.rs`):

```rust
#![warn(dead_code_pub_in_binary)]
```

Mark private crates `publish = false`, commit `Cargo.lock`, and use `--locked` in verification. Select release and CI build profiles deliberately; verify the profile used to ship if its behavior differs from the test build.

### 6.3 Unsafe, FFI, and systems code

Opt in to `unsafe_code` only in the crate or module that owns the unsafe operation. Keep `unsafe_op_in_unsafe_fn` and `clippy::undocumented_unsafe_blocks` at `deny`. Keep `clippy::multiple_unsafe_ops_per_block`, `clippy::missing_safety_doc`, and `clippy::non_send_fields_in_send_ty` active. Appendix A.1 already enables them. Document caller preconditions under `# Safety` for every `unsafe fn` and `unsafe trait`. At each unsafe operation, give a `// SAFETY:` argument that establishes the relevant aliasing, provenance, alignment, lifetime, initialization, ABI, and thread-safety requirements.

Prefer checked representation APIs in `bytemuck` or `zerocopy` to `std::mem::transmute`. For a zero-sized type, prefer Rust 1.100's `std::mem::conjure_zst` over a ZST transmute, subject to its preconditions. For heavy register, graphics, or pixel math, establish widths, ranges, and rounding at the conversion boundary. Scope any necessary cast adjustment there under Section 2 instead of disabling pedantic cast checks crate-wide.

Run `cargo +nightly miri test` on Miri-executable unsafe paths; pin a dated nightly in CI. Miri cannot execute most OS, FFI, or network calls. Exercise those boundaries with native integration tests. Verify shipped operating systems and architectures separately when layout, ABI, or pointer width can differ.

### 6.4 Async Rust (Tokio and executors)

- End a `std::sync::Mutex` guard or `RefCell` borrow before `.await`. Keep `await_holding_lock` and `await_holding_refcell_ref` active; Appendix A.1 already enables both. Do not perform blocking I/O, sleep, or process waits on executor worker threads. Use async APIs or a blocking worker and ban the known synchronous entry points under Section 5.6.
- Give spawned tasks an owner. Use `JoinSet` to collect outcomes and `tokio_util::sync::CancellationToken` (from `tokio-util`) for cooperative shutdown rather than detaching a `tokio::spawn` handle. Prefer bounded channels to `unbounded_channel`; define what the producer does under backpressure.
- Audit both cancel safety (dropping and retrying the future) and cancel correctness (the system's state after cancellation) in `tokio::select!` and `timeout`. Reserve channel capacity before moving a message, and pin a future across loop iterations when progress must survive selection. Never leave half-finished shared state across `.await` under a lock.
- Specify whether futures returned by public trait methods must be `Send`. Address `async_fn_in_trait` with explicit future bounds when callers need to spawn the result. Inspect captures and data held across awaits before boxing a `large_futures` finding.
- Use `#[tokio::test(start_paused = true)]` for timer-driven tests. Enable `test-util` in `[dev-dependencies]` only. Advance the clock or synchronize on the actual event instead of sleeping.

### 6.5 `no_std` and embedded targets

Declare the environment and its checks in the crate root:

```rust
#![no_std]
#![warn(
    clippy::std_instead_of_core,
    clippy::std_instead_of_alloc,
    clippy::alloc_instead_of_core
)]
```

Check the actual `--target` and feature set without host-only dependencies. State which binary supplies the panic handler and whether allocation is available. Run pure logic tests on the host; verify device startup, peripherals, panic behavior, and timing on the supported hardware.

## 7. Formatting, dependencies, and artifacts

### 7.1 Formatter ownership (`rustfmt`)

Let rustfmt own Rust layout. Set `edition = "2024"` in `rustfmt.toml` to select the 2024 parser and corresponding style edition. Setting only `style_edition = "2024"` leaves bare `rustfmt` parsing as 2015. Use stable options from the installed formatter (`rustfmt --help=config`); rustfmt 1.11.0-stable has 29. `hex_literal_case` stabilized with Rust 1.99. `ignore`, `imports_granularity`, `group_imports`, `wrap_comments`, and `format_code_in_doc_comments` remain nightly-only. Do not depend on CLI `--config` quirks to enable them.

Use `#[rustfmt::skip]` on the specific generated or byte-sensitive item that must retain its layout. If the repository formats TOML with Taplo or sorts manifests with cargo-sort, assign one owner to each transformation so the tools do not undo one another.

### 7.2 Dependency, advisory, and supply-chain hygiene

Use cargo-deny 0.22.2 or later with the current schema in Appendix A.5. Omit the legacy `version = 2` marker.

| Table          | Required policy                                                                                                                                                                                                     |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `[advisories]` | Check `unmaintained = "workspace"` and `unsound = "all"`. Review yanked packages. Scope each necessary advisory ignore to `{ id, reason, expiry }`; remove it when fixed or expired.                                |
| `[bans]`       | Review `multiple-versions = "warn"` and deny wildcards. `allow-wildcard-paths = true` permits private path dependencies for `publish = false` crates. Use a version and path for publishable internal dependencies. |
| `[licenses]`   | Set an explicit SPDX allowlist that matches the repository's actual license policy and dependency graph.                                                                                                            |
| `[sources]`    | Deny `unknown-registry` and `unknown-git`. Name authorized sources explicitly.                                                                                                                                      |

Local-only repositories may use `--offline` with a refreshed, cached advisory database. Record its revision or refresh date; offline results describe that data, not advisories published since. Use cargo-audit for a lockfile-only scan or to scan shipped binaries built with `cargo-auditable`. Use Cargo 1.100's registry `min-publish-age` to apply an intentional cooldown to registry upgrades. A cooldown does not replace advisory checks.

Run `cargo::unused_dependencies` and `cargo::unused_workspace_dependencies`. Add cargo-shear 1.14.1 or later for development dependencies that Cargo does not check. Inspect target, feature, build, and proc-macro use before removing a dependency. Use cargo-vet only when a team owns the actual audit reviews. For vendored or `[patch.crates-io]` dependencies, record upstream origin, exact revision, checksums, local changes, and removal conditions. Verify the checksum and test the resolved copy, not a registry substitute.

### 7.3 Generated code and build scripts

Name the generator, its inputs and version, the output owner, and the command that reproduces checked-in output. Verify freshness without rewriting the working tree: generate into a temporary directory and compare, or use the generator's check mode. Compile and exercise the generated code through its consumer.

Make `build.rs` deterministic for its declared inputs. Emit `cargo::rerun-if-changed=...` for source inputs and declare any configuration inputs that affect the result. Keep network calls out of the build. Fetch or vendor external inputs through the repository's dependency process.

## 8. Verification and enforcement integrity

### 8.1 Focused gate integrity — no stock-lint proof tests

Run the real acceptance commands. Do not write tests that prove rustc rejects invalid code, Clippy detects one of its stock findings, or rustfmt changes whitespace. Do not parse Makefile recipes to check whether a flag appears: that cannot show whether the gate runs on a workspace member or preserves a failure.

Test behavior the repository owns. For an `xtask` policy check, exercise a real manifest or attribute that native checks miss. For a generator, show that stale output fails the freshness check. For an architecture boundary, test the domain contract a violation would break. A passing gate must include the affected code and propagate its exit status.

### 8.2 Testing standards and runners

Use `CARGO_BUILD_WARNINGS=deny cargo test --workspace --locked` by default. Test returned values, error variants, cause chains, edge inputs, and observable state changes. A suite of happy paths or `assert!(res.is_ok())` does not establish the operation's contract.

For process-per-test isolation, leak detection (`leak-timeout`), slow-test termination (`slow-timeout`), and JUnit output, use cargo-nextest 0.9.152 or later (security floor 0.9.150). **Always pair nextest with `CARGO_BUILD_WARNINGS=deny cargo test --workspace --locked --doc`.** Nextest does not run doctests.

Edition 2024 makes `std::env::set_var` and `std::env::remove_var` unsafe. Inject configuration or set the environment of a child process instead of mutating shared process state. Synchronize tests on observable events rather than sleeps. Use `proptest` for generative invariants, `insta` for reviewed snapshots, `trybuild` for compile-time contracts, `cargo-llvm-cov` for measured coverage, or `cargo-mutants` to evaluate assertion strength when the result answers a concrete question.

### 8.3 Evidence quality

Record the commit SHA or PR, exact toolchain versions, target triples, feature sets, commands, and exit codes. Separate evidence of compilation from unit and integration test execution, doctests, Miri, and live platform or hardware checks. A host check cannot verify a device interrupt handler. A Miri pass cannot verify a native library's ABI.

Use hosted CI or a documented local-only gate. In either case retain the actual result, identify untested combinations, and do not claim a broader scope than the commands covered.

## 9. Adoption, upgrades, and escalation

### 9.1 Inspect the target repository first

Record the starting Git revision and preserve unrelated uncommitted work. Read repository instructions, manifests, toolchain and formatter configuration, source attributes, lockfile, CI jobs, release commands, and existing exception records. Use Cargo metadata to enumerate the members and targets. Map the supported features, platforms, MSRV, consumers, and profiles. Run the existing gate before changing it and distinguish baseline failures from regressions.

### 9.2 First-time adoption

1. Record scope and applicable profiles in Appendix B. Preserve stricter checks that already protect a contract.
2. Select current quality tools. Apply Appendix A, verify inheritance member by member, and map checks to supported feature sets and targets.
3. Fix findings in the owning code. Preserve errors, drop order, public API, and actual test assertions. Use Section 2 only for demonstrated exceptions.
4. Run Section 10.1 and the profile-specific checks. Record exact evidence, including separate MSRV, platform, and doctest results where applicable.

### 9.3 Upgrading an existing Rust repository (delta workflow)

Compare the adopted baseline and tool versions with the new requirements. Identify changed lint groups, moved or removed lints, stable options, thresholds, profile coverage, and native features that replace local workarounds. Apply that delta without overwriting local policy with a fresh starter file. Inventory repository-owned policy tests, generator freshness checks, and CI wiring before removing obsolete suites. Keep checks that protect repository behavior. Retire stale vendored copies of the standard and update their callers to use the canonical URL. Re-evaluate exceptions against the new toolchain, remove stale suppressions, and run the acceptance matrix on the resulting revision.

### 9.4 Raising regressions to the driving user

If a mandate breaks behavior, degrades safety, conflicts with current upstream behavior, or forces a harmful workaround, report it directly to the user driving the work before relaxing enforcement. Provide the exact command, tool versions, diagnostic, affected contract, and a realistic compliant alternative. Show the observed difference and the narrowest proposed resolution. A note buried in an adoption record is not escalation.

### 9.5 Preserving and surfacing stronger repository conventions

Retain stronger checks with evidence that they prevent a real failure without forcing worse code. Check for contradictions before composing them: do not combine `clippy::implicit_return` with `clippy::needless_return`, or `mod_module_files` with `self_named_module_files`. Show the driving user the rule, its scope, and a concrete benefit so it can be considered for upstream adoption. Do not silently replace it with the weaker starter setting.

## 10. Acceptance and maintenance

### 10.1 Required commands and CI

Run the following commands from the workspace root. Add the supported targets, features, and profile checks recorded in Appendix B. Keep the commands runnable locally even when hosted CI also runs them.

```sh
cargo fmt --all -- --check
CARGO_BUILD_WARNINGS=deny cargo clippy --workspace --all-targets --locked
CARGO_BUILD_WARNINGS=deny cargo test --workspace --locked
CARGO_BUILD_WARNINGS=deny cargo doc --workspace --locked --no-deps
cargo deny --locked --workspace check
```

When using nextest, replace the test line with **both** commands below. `--profile ci` requires `[profile.ci]` in `.config/nextest.toml` (Appendix A.6). Without that profile nextest exits with code 96. Omit `--profile ci` to use the default profile; keep the separate doctest command.

```sh
CARGO_BUILD_WARNINGS=deny cargo nextest run --workspace --locked --profile ci --no-fail-fast
CARGO_BUILD_WARNINGS=deny cargo test --workspace --locked --doc
```

For compact agent triage, run `CARGO_BUILD_WARNINGS=deny cargo clippy --workspace --all-targets --locked --message-format=short`. A repository without hosted CI may run the same gate locally. When offline, use `cargo deny --offline --locked --workspace check` with a refreshed advisory database.

Measure before optimizing CI. In a disposable job using `sccache`, evaluate `CARGO_INCREMENTAL=0` against actual cache hits and elapsed time. Rust 1.90 and later already default to LLD on `x86_64-unknown-linux-gnu`. Evaluate `mold` only if linking is a measured bottleneck.

### 10.2 Completion criteria

Acceptance requires passing commands for the declared matrix, zero compiler, Cargo, Clippy, and rustdoc warnings in the quality job, and no unexplained dependency findings. Verify the formatted tree, inherited settings, applicable profiles, generated freshness, and actual behavior at the supported boundaries. Record the command outcomes and reviewed exceptions. State precisely what was compiled, what was executed, and where.

### 10.3 Ongoing maintenance

Point `AGENTS.md` or `CLAUDE.md` to the canonical standard at `https://fitchhub.com/standards/rust.md`. In the same instructions, name the repository's canonical acceptance command and the location of its Appendix B record. Use the pinned release URL only in the Appendix B adoption record, so future work finds the current guidance. Upgrade toolchains intentionally: read release notes, review effective lints and schemas, update reproducible pins, run both the quality and MSRV jobs, and retire workarounds that no longer apply.

## Appendix A: Starter configurations

### A.1 Workspace `Cargo.toml`

```toml
[workspace]
resolver = "3"
members = ["crates/*"]

[workspace.package]
version = "0.1.0"
edition = "2024"
rust-version = "1.100"
license = "MIT OR Apache-2.0"
publish = false

[workspace.lints.cargo]
missing_lints_inheritance = "warn"
unused_dependencies = "warn"
unused_workspace_dependencies = "warn"
unused_workspace_package_fields = "warn"
blanket_hint_mostly_unused = "warn"
redundant_homepage = "warn"
unknown_lints = "warn"

[workspace.lints.rust]
unsafe_code = "deny"
unsafe_op_in_unsafe_fn = "deny"
unused_must_use = "deny"
non_ascii_idents = "deny"
unfulfilled_lint_expectations = "warn"
unreachable_pub = "warn"
redundant_imports = "warn"
redundant_lifetimes = "warn"
unused_lifetimes = "warn"
unused_macro_rules = "warn"
let_underscore_drop = "warn"
unit_bindings = "warn"
ambiguous_negative_literals = "warn"
closure_returning_async_block = "warn"
deref_into_dyn_supertrait = "warn"
macro_use_extern_crate = "warn"
meta_variable_misuse = "warn"

[workspace.lints.rustdoc]
broken_intra_doc_links = "warn"
private_intra_doc_links = "warn"
invalid_html_tags = "warn"
invalid_rust_codeblocks = "warn"
invalid_markdown_table = "warn"
bare_urls = "warn"

[workspace.lints.clippy]
correctness = { level = "deny", priority = -1 }
suspicious = { level = "warn", priority = -1 }
complexity = { level = "warn", priority = -1 }
perf = { level = "warn", priority = -1 }
style = { level = "warn", priority = -1 }
pedantic = { level = "warn", priority = -1 }

# Deliberate pedantic opt-outs (see Section 5.4)
assigning_clones = "allow"
doc_markdown = "allow"
if_not_else = "allow"
implicit_hasher = "allow"
items_after_statements = "allow"
map_unwrap_or = "allow"
missing_errors_doc = "allow"
missing_panics_doc = "allow"
must_use_candidate = "allow"
return_self_not_must_use = "allow"
similar_names = "allow"
struct_excessive_bools = "allow"
too_many_lines = "allow"

# Curated anti-slop restriction lints (never enable `restriction` wholesale)
allow_attributes = "warn"
allow_attributes_without_reason = "warn"
assertions_on_result_states = "warn"
cfg_not_test = "warn"
clone_on_ref_ptr = "warn"
cognitive_complexity = "warn"
dbg_macro = "warn"
empty_drop = "warn"
exit = "warn"
expect_used = "warn"
fn_to_numeric_cast_any = "warn"
indexing_slicing = "warn"
infinite_loop = "warn"
let_underscore_must_use = "deny"
lossy_float_literal = "warn"
map_err_ignore = "warn"
mem_forget = "warn"
multiple_unsafe_ops_per_block = "warn"
mutex_atomic = "warn"
mutex_integer = "warn"
panic = "warn"
print_stderr = "warn"
print_stdout = "warn"
rc_buffer = "warn"
rc_mutex = "warn"
rest_pat_in_fully_bound_structs = "warn"
string_slice = "warn"
todo = "warn"
undocumented_unsafe_blocks = "deny"
unimplemented = "warn"
unnecessary_safety_comment = "warn"
unnecessary_safety_doc = "warn"
unused_result_ok = "warn"
unwrap_used = "warn"
verbose_file_reads = "warn"

# High-signal nursery cherry-picks (never enable `nursery` wholesale)
collection_is_never_read = "warn"
debug_assert_with_mut_call = "warn"
fallible_impl_from = "warn"
non_send_fields_in_send_ty = "warn"
redundant_clone = "warn"
significant_drop_in_scrutinee = "warn"
unused_peekable = "warn"
use_self = "warn"
```

For a single package without `[workspace]`, move `[workspace.lints.*]` to `[lints.*]`. Drop the workspace-only Cargo lints `missing_lints_inheritance`, `unused_workspace_dependencies`, and `unused_workspace_package_fields`.

### A.2 Member crate `Cargo.toml`

```toml
[package]
name = "example-crate"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
publish.workspace = true

[lints]
workspace = true
```

### A.3 `clippy.toml`

```toml
allow-dbg-in-tests = false
allow-expect-in-tests = true
allow-indexing-slicing-in-tests = true
allow-panic-in-tests = true
allow-print-in-tests = true
allow-unwrap-in-tests = true
cognitive-complexity-threshold = 20
excessive-nesting-threshold = 4
max-fn-params-bools = 1
```

### A.4 `rustfmt.toml`

```toml
edition = "2024"
max_width = 100
newline_style = "Unix"
use_field_init_shorthand = true
use_try_shorthand = true
```

### A.5 `deny.toml`

```toml
[advisories]
yanked = "warn"
unmaintained = "workspace"
unsound = "all"

[bans]
multiple-versions = "warn"
wildcards = "deny"
allow-wildcard-paths = true

[licenses]
allow = ["Apache-2.0", "MIT"]

[sources]
unknown-registry = "deny"
unknown-git = "deny"
```

Adjust `[licenses].allow` to the repository's actual license policy. cargo-deny warns on unmatched entries in `allow`. `allow-wildcard-paths = true` applies only to `publish = false` crates.

### A.6 Optional `.config/nextest.toml`

```toml
# Enforce the 0.9.150 security floor; install >= 0.9.152 for Section 5.1.
nextest-version = "0.9.150"

[profile.ci]
failure-output = "immediate"
leak-timeout = { period = "100ms", result = "fail" }
slow-timeout = { period = "30s", terminate-after = 4 }

[profile.ci.junit]
path = "junit.xml"
```

## Appendix B: Repository records

### Adoption record

Record the following details in the adopting repository. Link the pull request or tracking issue to avoid recording a commit SHA inside the commit it identifies:

- Standard: Rust Engineering Standard v1.0, `https://fitchhub.com/standards/rust/v1.0.md`
- Repository, pull request or tracking issue, date, owner:
- Workspace members, private and publishable crates, excluded code and reason:
- Quality toolchain pin and actual tool versions; member lint inheritance:
- Stronger local checks, reviewed exceptions, and regression escalations:
- Dependency policy, advisory database revision, generated and patched code evidence:

Use one row per supported combination. Distinguish compilation from execution.

| Member / profile | Target triple | Features | Compiler / declared MSRV | Command | Hosted CI job or local gate | Exit code and evidence |
| ---------------- | ------------- | -------- | ------------------------ | ------- | --------------------------- | ---------------------- |
|                  |               |          |                          |         |                             |                        |

### Quality-exception record

- ID: `QX-001`
- Owner, date, affected member and item:
- Toolchain, lint, options, target and features, command, observed diagnostic:
- Supported contract and best compliant alternative:
- Demonstrated harm or disproportionate complexity:
- Narrowest adjustment, exact attribute or configuration, and reason:
- Remaining type, boundary, behavioral, or unsafe verification evidence:
- Review decision, removal condition, and next review:

## Appendix C: Changelog

### v1.0 (30 November 2026)

Initial Edition 2024 standard. Defines workspace lint inheritance, warning enforcement, structural thresholds, exception evidence, and dependency policy. Adds composable library, binary, unsafe, async, and embedded profiles with acceptance commands and starter manifests.

## References

Primary references for the 30 November 2026 baseline:

- [Rust 1.100.0 release](https://blog.rust-lang.org/2026/11/12/Rust-1.100.0/) and [Rust 1.100.1 regression fix](https://blog.rust-lang.org/2026/11/27/Rust-1.100.1/)
- [Cargo lints](https://doc.rust-lang.org/cargo/reference/lints.html), [Cargo `build.warnings`](https://doc.rust-lang.org/cargo/reference/config.html#buildwarnings), and [Cargo resolver 3 in Edition 2024](https://doc.rust-lang.org/edition-guide/rust-2024/cargo-resolver.html)
- [rustc lint levels](https://doc.rust-lang.org/rustc/lints/levels.html) and [allowed-by-default lints](https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html)
- [Clippy lint list](https://clippy.rust-lang.org/stable/index.html) and [Clippy configuration](https://doc.rust-lang.org/clippy/lint_configuration.html)
- [rust-lang/rust#159078](https://github.com/rust-lang/rust/issues/159078): `dead_code_pub_in_binary` checks public library items in unit-test builds.
- [rustdoc lints](https://doc.rust-lang.org/rustdoc/lints.html)
- [rustfmt style edition](https://doc.rust-lang.org/edition-guide/rust-2024/rustfmt-style-edition.html) and [rustfmt configuration](https://rust-lang.github.io/rustfmt/)
- [cargo-deny](https://embarkstudios.github.io/cargo-deny/) and [cargo-nextest](https://nexte.st/)
- [cargo-shear](https://github.com/Boshen/cargo-shear), [cargo-hack](https://github.com/taiki-e/cargo-hack), and [cargo-semver-checks](https://github.com/obi1kenobi/cargo-semver-checks)
- [Miri](https://github.com/rust-lang/miri)
- [Rust 1.90 release: LLD on x86_64 Linux](https://blog.rust-lang.org/2025/09/18/Rust-1.90.0/)
