← Archive

Stress-testing agent standards on real code

Six ordinary ways to ignore a Rust result failed the same CI check. One diagnostic told me to use let _ =. Another rejected that exact fix. Each rule made sense on its own.

I found the conflict while testing my Rust standard on an actively evolving Rust workspace of about 390,000 lines. Its 14 crates span a static recompiler, a runtime, a shader compiler, and a Metal 4 backend. The TypeScript rollout exposed the same problem: an agent can follow every instruction and leave you with worse code.

Treat a standard like production code. Run the whole configuration against real repositories before you publish it. Read what the tools ask the agent to change.

Six ways to discard a result, six failures

Link to Six ways to discard a result, six failures

write! can fail when it writes to a file. Here it formats a usize into a String, so there is no write or formatting error to handle:

use std::fmt::Write as _;

pub fn append_number(buf: &mut String, x: usize) {
	write!(buf, "{x}");
}

The return type, Result<(), std::fmt::Error>, is Copy and marked #[must_use]. Under Rust standard v1.1, the warning-denying CI job rejects six forms of the same call:

FormWhy CI rejects it
expr;unused_must_use requires you to use or explicitly discard the result.
expr.ok();clippy::unused_result_ok suggests “consider using let _ = and removing the call to .ok() instead.”
let _ = expr;clippy::let_underscore_must_use is set to "deny".
drop(expr);dropping_copy_types warns that dropping a Copy value does nothing.
expr.unwrap();clippy::unwrap_used rejects it in production code.
expr.expect("write to String");clippy::expect_used rejects it in production code.

OnceLock::<usize>::set and AtomicUsize::compare_exchange also return Copy results. clippy.toml can exempt unwrap and expect in tests, but it has no test exemption for let_underscore_must_use.

Rust v1.2 removes the conflicting lint. When both outcomes are acceptable, use let _ = expr; for a Copy result marked #[must_use]. Use drop(expr); for a non-Copy value with a destructor. The retained let_underscore_drop lint requires you to make that immediate destruction explicit. If the caller needs the error, handle it or propagate it with ?.

A file-extension lint flagged an LLVM name

Link to A file-extension lint flagged an LLVM name
pub fn is_i32_intrinsic(name: &str) -> bool {
	name.ends_with(".i32")
}

case_sensitive_file_extension_comparisons checks string suffixes, even when the string has nothing to do with a file. For ASCII suffixes on &str or String, it looks for a literal dot followed by one to five letters or digits. At least one must be a letter, and the letters must share a case. It skips recognized case conversions on the receiver.

Clippy suggested std::path::Path::new(name).extension() and eq_ignore_ascii_case("i32"). That fix makes .I32 match too, even though the shader compiler needs an exact match. v1.2 drops the string lint and keeps clippy::path_ends_with_ext for actual Path values.

Check what Cargo actually passes to the compiler

Link to Check what Cargo actually passes to the compiler

In .cargo/config.toml, a project can set flags for its target:

[target.aarch64-apple-darwin]
rustflags = ["-C", "target-cpu=native"]

RUSTFLAGS="-D warnings" cargo check -vv replaces those flags. The compiler invocation loses -C target-cpu=native without a warning about the change. CARGO_BUILD_WARNINGS=deny cargo check -vv keeps the target flags and fails on a compiler warning. Cargo stabilized build.warnings in 1.97.

The compiler pin and the minimum supported Rust version also do different jobs. Suppose an internal package has these entries in Cargo.toml:

[package]
name = "lint-note"
version = "0.1.0"
edition = "2021"
publish = false
rust-version = "1.70"

[lints.clippy]
allow_attributes = "warn"

Even if rust-toolchain.toml pins Rust 1.100.1, Clippy uses rust-version to decide which fixes the package can adopt. With the manifest above, cargo clippy leaves this code alone:

#[allow(unused_variables, reason = "demonstrate the lint")]
pub fn example() {
	let unused = 1;
}

Remove rust-version and Clippy suggests #[expect], which Rust 1.70 did not support. Keep the minimum version if the crate supports it. An internal workspace that only builds with its pinned compiler gains nothing by declaring an older version it never tests.

The public API check unreachable_pub produced more than 1,100 warnings in the unpublished crates. It flags pub fn items inside private modules even when other code in the crate calls them. Those warnings tell you about access from other crates. dead_code addresses the unused-code question. v1.2 moves unreachable_pub to the public-library profile.

Count by rule before asking for fixes

Link to Count by rule before asking for fixes

On 391,000 lines of systems Rust, 88% of diagnostics came from three groups: slice indexing, changes in integer width with as, and unsafe blocks. The other 12% included incorrect unsafe impl Send declarations (non_send_fields_in_send_ty), pointer casts with insufficient alignment (cast_ptr_alignment), and derived deserializers that could bypass invariants (unsafe_derive_deserialize).

Some indexing warnings mark real bugs. Others flag code where a boundary check already proves the index is in range. An instruction to fix every warning in one pass gives the agent no reason to tell the difference. Review the thread-safety and alignment findings first. Keep the indexing checks where they catch unchecked input or arithmetic, and use narrow exceptions where the code already proves the bounds.

The TypeScript rollout had its own compliance shims, changes made only to satisfy a check. Agents added fake await Promise.resolve() calls or used as unknown as to silence type errors. Neither makes the program safer. Read the installed Oxlint configuration and check the real file list with oxlint --debug=files. The Oxlint and Oxfmt standard uses tsrs for type-aware linting and still runs the project's compiler check. oxlint --type-check does not report file-level errors in files Oxlint skips.

Publish a version and give agents room to report bad rules

Link to Publish a version and give agents room to report bad rules

The standards index links to rendered pages like the Rust standard. /llms.txt lists the raw Markdown endpoints, including Rust and Oxlint and Oxfmt. Point your agent at the latest Markdown and record the version you validated in the repo.

Published versions stay frozen. The dated notice on Rust v1.1 names the known errors so you can still see why the old configuration failed. The corrections live in v1.2.

Put a sentence like this next to the Markdown link in your project instructions:

Apply the checks that protect correctness and safety. Skip rules that add complexity without a concrete benefit. Name the rule, show the code it flags, and explain why the narrow exception preserves the behavior. Keep stronger local checks that work.

Run candidate rules across a large codebase before you ship them. If the suggested fix makes the code worse, fix the standard before you ask an agent to change the code.