From 1434db626afd0bc90105c12ae7a162a7bb941333 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sun, 4 Oct 2026 13:12:21 -0400 Subject: [PATCH 1/2] Never crash: deny the panic lints in crates that are already clean annot, compare, content, cos, export, geom, model, ocr, preflight, print and redact have no production `unwrap`/`expect`/`panic!`/`unreachable!`/`todo!`/`unimplemented!`. The attribute keeps it that way. Co-Authored-By: Claude Opus 5.5 --- crates/annot/src/lib.rs | 2 ++ crates/compare/src/lib.rs | 2 ++ crates/content/src/lib.rs | 2 ++ crates/cos/src/lib.rs | 2 ++ crates/export/src/lib.rs | 2 ++ crates/geom/src/lib.rs | 2 ++ crates/model/src/lib.rs | 2 ++ crates/ocr/src/lib.rs | 2 ++ crates/preflight/src/lib.rs | 2 ++ crates/print/src/lib.rs | 2 ++ crates/redact/src/lib.rs | 2 ++ 11 files changed, 22 insertions(+) diff --git a/crates/annot/src/lib.rs b/crates/annot/src/lib.rs index f49655f6..6a7d8812 100644 --- a/crates/annot/src/lib.rs +++ b/crates/annot/src/lib.rs @@ -12,6 +12,8 @@ //! Every edit mutates a `printcraft_cos::Document` (copy-on-write); callers snapshot it first //! for undo. Keys we do not understand are left alone. +#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)] + use printcraft_cos::{Dict, Document, ObjRef, Object, PdfString}; pub mod appearance; diff --git a/crates/compare/src/lib.rs b/crates/compare/src/lib.rs index 5141f93f..31e661c5 100644 --- a/crates/compare/src/lib.rs +++ b/crates/compare/src/lib.rs @@ -5,6 +5,8 @@ //! grouped into [`Change`]s — inserted, deleted or replaced runs of words — each with the //! rectangles to highlight on the old and new pages. +#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)] + /// A word of one document. #[derive(Clone, Debug, PartialEq)] pub struct Word { diff --git a/crates/content/src/lib.rs b/crates/content/src/lib.rs index 0f0489b4..c541d701 100644 --- a/crates/content/src/lib.rs +++ b/crates/content/src/lib.rs @@ -5,6 +5,8 @@ //! [`Parsed::skipped`]) instead of failing the whole stream, and it never panics. Inline images //! (`BI … ID … EI`) are kept whole, so a parse → serialize round trip preserves them. +#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)] + use printcraft_cos::{Dict, Lexer, Object, PdfString, serialize}; #[cfg(test)] diff --git a/crates/cos/src/lib.rs b/crates/cos/src/lib.rs index 45409b4d..ad85c4f8 100644 --- a/crates/cos/src/lib.rs +++ b/crates/cos/src/lib.rs @@ -9,6 +9,8 @@ //! incremental and full writing. Not yet: encryption (M1.6), object-stream / xref-stream output //! for full saves, linearization (M11). +#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)] + mod document; mod object; mod parser; diff --git a/crates/export/src/lib.rs b/crates/export/src/lib.rs index c7a12022..a45bec49 100644 --- a/crates/export/src/lib.rs +++ b/crates/export/src/lib.rs @@ -5,6 +5,8 @@ //! document: headings are the paragraphs set larger than the body text, and images sit where //! they fall between paragraphs. +#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)] + mod zip; pub use zip::Zip; diff --git a/crates/geom/src/lib.rs b/crates/geom/src/lib.rs index 75ff3a42..eaa109c6 100644 --- a/crates/geom/src/lib.rs +++ b/crates/geom/src/lib.rs @@ -3,6 +3,8 @@ //! PDF user space is y-up with the origin at the bottom-left of the page; view space is y-down. //! `PageRect` is always in PDF user space (points, 1/72 inch). +#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)] + /// An axis-aligned rectangle in PDF user space (points). #[derive(Clone, Copy, Debug, PartialEq, Default)] pub struct PageRect { diff --git a/crates/model/src/lib.rs b/crates/model/src/lib.rs index d28f0d4e..9d2c9feb 100644 --- a/crates/model/src/lib.rs +++ b/crates/model/src/lib.rs @@ -1,5 +1,7 @@ //! printcraft-model — typed views over the PDF object graph (L2). See the README. +#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)] + use printcraft_cos::{Dict, Document, ObjRef, Object}; /// Attributes a page inherits from its ancestors (ISO 32000-2 §7.7.3.4). diff --git a/crates/ocr/src/lib.rs b/crates/ocr/src/lib.rs index 755fc3e4..026dda97 100644 --- a/crates/ocr/src/lib.rs +++ b/crates/ocr/src/lib.rs @@ -8,6 +8,8 @@ //! //! The models read the Latin alphabet (English and other languages written without accents). +#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)] + use std::path::{Path, PathBuf}; pub use printcraft_fonts::helvetica_width; diff --git a/crates/preflight/src/lib.rs b/crates/preflight/src/lib.rs index a0cfe2b2..beb78dc3 100644 --- a/crates/preflight/src/lib.rs +++ b/crates/preflight/src/lib.rs @@ -19,6 +19,8 @@ //! intent, forbidden actions, annotation flags, Interpolate, NeedAppearances, encryption) and //! returns what remains. Fonts that aren't embedded can't be fixed here. +#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)] + pub mod icc; mod xmp; diff --git a/crates/print/src/lib.rs b/crates/print/src/lib.rs index ad94ea09..a0ef7989 100644 --- a/crates/print/src/lib.rs +++ b/crates/print/src/lib.rs @@ -15,6 +15,8 @@ //! The sheets are written as a new, unencrypted, garbage-collected PDF; [`spool`] hands it to //! the system's print spooler (CUPS on macOS and Linux). +#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)] + use printcraft_content::Matrix; use printcraft_cos::{Dict, Document, ObjRef, Object, SaveOptions, Stream, write_full}; diff --git a/crates/redact/src/lib.rs b/crates/redact/src/lib.rs index dd310a88..57189ade 100644 --- a/crates/redact/src/lib.rs +++ b/crates/redact/src/lib.rs @@ -12,6 +12,8 @@ //! A verification pass then re-reads every redacted page; if any glyph or inline image is still //! under a region the whole operation fails (callers keep the previous document: fail-closed). +#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)] + use printcraft_cos::{Dict, Document, ObjRef, Object, Stream}; mod image; From 59f74ea38667a9fff4b559ab263a5151614385e3 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sun, 4 Oct 2026 13:35:01 -0400 Subject: [PATCH 2/2] Root clippy.toml: tests may unwrap, expect, panic and index MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The same file as the steering PR (#11), so this PR stands on its own. The crate-level `#![deny(clippy::unwrap_used, …)]` applies to production code only. Co-Authored-By: Claude Opus 5.5 --- clippy.toml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 clippy.toml diff --git a/clippy.toml b/clippy.toml new file mode 100644 index 00000000..4b6c79f5 --- /dev/null +++ b/clippy.toml @@ -0,0 +1,4 @@ +allow-unwrap-in-tests = true +allow-expect-in-tests = true +allow-panic-in-tests = true +allow-indexing-slicing-in-tests = true