Skip to content
CAI
Software that uses CAICheck a score

dtolnay/thiserror

68.7

Adequate · 30 September 2026

2.7k

lines of production code

Rust

primary language

2

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

This system is the thiserror crate, a Rust library that provides a derive macro to automatically implement the std::error::Error trait for custom types. It enables developers to define error types with custom display messages, source error chaining, and backtrace support through declarative attributes. The implementation includes comprehensive validation, no-std compatibility, and robust test coverage to ensure correct code generation and clear compiler diagnostics.

Features

Initial implementation of the thiserror derive macro

This change introduces the core implementation for the \thiserror\ crate's \\#\[derive(Error)\]\ macro. It adds the internal \impl/src\ module containing the AST definitions, attribute parsing, format string expansion, code generation, and validation logic required to automatically implement \std::error::Error\, \Display\, and \From\ for user-defined types. This enables users to derive error types with custom display messages, source error chaining, and backtrace support.

impl/src · high confidence

Behavioural changes

Dual-licensed under MIT OR Apache-2.0

The project now offers users a choice of license, providing both the MIT and Apache License 2.0 texts. This allows downstream consumers to select the license that best fits their project's requirements, rather than being restricted to a single licensing option.

(repo-wide) · high confidence

Internal implementation refactoring for error formatting and trait sealing

The library's internal source files have been restructured to improve trait safety and formatting consistency. The private \AsDynError\ and \AsDisplay\ traits are now sealed to prevent external implementation, and the \AsDisplay\ trait specifically wraps interpolated variables to correctly forward the \Pointer\ trait for path formatting. Additionally, the \Var\ wrapper ensures that pointer-style formatting is handled consistently, and the \ThiserrorProvide\ trait is introduced to support the standard library's \Error::provide\ API for backtrace forwarding.

src · high confidence

Refactor build-time feature probe into a standalone file

The build script's detection logic for the \error\_generic\_member\_access\ feature has been moved from an inline string literal into a dedicated \build/probe.rs\ file. This change improves maintainability and ensures that the \RUSTC\_BOOTSTRAP\ environment variable is correctly tracked in the dependency info, which aids in accurate caching (e.g., via sccache) when the Rust compiler bootstrap flag is used.

build · high confidence

Test coverage

Added no-std compatibility tests; Comprehensive test suite for thiserror macro; Expanded UI test coverage for thiserror derive macro validation.

Dependencies

thiserror 2.0.21: Rust 1.77 requirement, syn 3 upgrade, and no-std support

This release updates the thiserror crate to version 2.0.21, raising the minimum required Rust compiler version to 1.77. The implementation dependency has been upgraded from syn 2 to syn 3, and the crate now supports no-std environments via a new \std\ feature flag (enabled by default). The project structure has been reorganized into a workspace containing the main crate, the \thiserror-impl\ proc-macro crate, and a dedicated \tests/no-std\ test package.

(dependencies) · high confidence

Housekeeping

License files linked in impl subcrate

The impl subcrate now includes symlinks to the project's Apache-2.0 and MIT license files, ensuring that license information is accessible within this specific component.

impl · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 68 → 69 (+0.6)
  • Rubric changed (rubric-2026.09.10 → rubric-2026.09.18) — scores are not directly comparable.

Lenses

  • Code Health 85 → 84 (-0.7)
  • Architecture 100 → 100 (+0.0)
  • Maturity 57 → 57 (+0.0)
  • Readiness 60 → 66 (+5.7)
  • Security 100 → 100 (+0.0)

Resolved (1)

  • Documentation: no installation or build instructions (README.md)

New (3)

  • Dependency hygiene PARTLY measured — Cargo dependencies read, no committed lock to grade for currency
  • Inverted test pyramid
  • thiserror_impl::attr::parse_token_expr (cyclomatic 19) (impl/src/attr.rs)

Changes since last survey

  • 8 commits — 8 feature/other, 0 fixes

By area

  • (root) — 3 commits
  • tests/ui — 2 commits
  • (repo) — 1 commit
  • impl/src — 1 commit
  • tests/test_source.rs — 1 commit

Notable commits

  • change: Keep track of nested turbofish depth
  • change: Merge pull request #459 from dtolnay/turbofish
  • change: Raise required compiler to Rust 1.74
  • change: Raise required compiler to Rust 1.77
  • change: Release 2.0.21
  • change: Resolve io_other_error clippy lint in tests
  • change: Update ui test suite to nightly-2026-09-22
  • change: Update ui tests for version 2.0.21

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

dtolnay/thiserror was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 30 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 40e87c524be1d48c1580274a677d25eb2c49862f — the exact code this score is about.
  • Scored under rubric-2026.09.18 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-505904ce13c1.