From c415f14dd0d87566eae1ea29f4f2a4a6aed18702 Mon Sep 17 00:00:00 2001 From: smarm-agent Date: Sat, 20 Jun 2026 17:47:44 +0000 Subject: [PATCH] ci: deny unwrap_used/expect_used on the library target MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add [lints.clippy] unwrap_used = "deny", expect_used = "deny" plus a tracked pre-commit hook running `cargo clippy --lib -- -D warnings`. Library code may not hide a panic behind unwrap/expect; panic!/unreachable! stay un-linted as the explicit sanctioned form. Gate is the library target only — tests and examples are not gated. A fresh clone must run `git config core.hooksPath .githooks` to enable the hook. --- .githooks/pre-commit | 8 ++++++++ Cargo.toml | 9 +++++++++ 2 files changed, 17 insertions(+) create mode 100755 .githooks/pre-commit diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..d09c049 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,8 @@ +#!/bin/sh +# smarm pre-commit gate: clippy the library (src/) with warnings as errors. +# unwrap_used / expect_used are denied (Cargo.toml [lints.clippy]): library +# code must not hide a panic behind unwrap/expect. Tests/examples are not gated. +set -eu +[ -f "$HOME/.cargo/env" ] && . "$HOME/.cargo/env" +cd "$(git rev-parse --show-toplevel)" +cargo clippy --lib -- -D warnings diff --git a/Cargo.toml b/Cargo.toml index b9171c7..f24a59f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,15 @@ rust-version = "1.95" [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ["cfg(loom)"] } +[lints.clippy] +# Library code must never hide a panic behind unwrap/expect. Both are denied; an +# intentional panic is written explicitly as `match { Err(e) => panic!(..) }`. +# panic!/unreachable! are deliberately left un-linted as the blessed explicit +# form. Enforced on the library target only (`cargo clippy --lib`); tests and +# examples unwrap freely and are not gated. +unwrap_used = "deny" +expect_used = "deny" + [features] default = ["rq-mutex"] smarm-trace = []