Rules / TAU-E002

Typed errors outside the edge

decided by Clippy kernel deny core deny edge –
Applies to tests: no Exceptions: #[expect] + reason

Why

Result<T, ()>, anyhow::Error and similar erase which failures are possible, so callers cannot handle them exhaustively.

Fix

Define an error enum (for example with thiserror) whose variants name each failure. Convert to anyhow/eyre only in edge crates.

What it checks

Lints: clippy::result_unit_err

Banned in kernel, core (type-erased error), 3 types: anyhow::Error, eyre::Report, color_eyre::Report

Seen in fixtures

rej-unit-error/src/lib.rs core

//! Untyped error. /// Parse something.////// # Errors/// Fails without saying why.pub fn parse(text: &str) -> Result<u8, ()> {    text.parse().map_err(drop)}

$ cargo tauten check

error[TAU-E002]: this returns a `Result<_, ()>`  --> rej-unit-error/src/lib.rs:7:1 (core crate `rej-unit-error`)  = rule: Typed errors outside the edge (decided by Clippy)  = fix: Define an error enum (for example with `thiserror`) whose variants name each failure. Convert to anyhow/eyre only in edge crates.
Fixture rej-unit-error (core) expects TAU-E002. Output captured at 0200db3.

In the terminal

cargo tauten explain TAU-E002

$ cargo tauten explain TAU-E002

TAU-E002: Typed errors outside the edge Why: `Result<T, ()>`, `anyhow::Error` and similar erase which failures are possible, so callers cannot handle them exhaustively. Fix: Define an error enum (for example with `thiserror`) whose variants name each failure. Convert to anyhow/eyre only in edge crates. Decided by: ClippyDecides: No `Result<_, ()>` error type outside the edge.Sees: resolved; complete: yesDoes not see: Code expanded from macros defined in other crates (clippy skips it); code disabled by `cfg`; build scripts.Applies to tests: noExceptions allowed: with #[expect(.., reason)]  kernel deny  core deny  edge -Lints: clippy::result_unit_errBanned (type-erased error): anyhow::Error, eyre::Report, color_eyre::Report