fack
Declarative Rust error derivation with no_std support and zero allocation in generated runtime code.
use *;
Installation
[]
= "0.2.0"
Design
- All derive behavior uses the single
#[error(...)]helper namespace - Generated implementations use
::coreunless an import root is selected - Format fields and source fields are resolved before expansion
fack-codegenexposes opaque parse, validate, and expansion stages for downstream tooling- Generated
Display,Error, andFromimplementations allocate nothing
Formatting
Named and tuple fields can be captured directly. Explicit Rust format arguments are also supported.
use *;
;
A custom formatter can be selected when a format string is not the right abstraction.
use *;
Sources
#[error(source(field))] exposes the selected field as the ordinary source. Direct, boxed, optional, and optional boxed sources are supported.
use *;
#[error(transparent(field))] requires exactly one non-optional field. Display forwards to that field and source chaining forwards through its own Error::source implementation.
use *;
;
Conversion
#[error(from)] requires exactly one field. It generates From<T> and makes that field the ordinary error source.
use *;
Generation options
Without an inline declaration, generated methods receive no explicit inline attribute. #[error(inline)] and #[error(inline(neutral))] emit ordinary #[inline]. The always and never strategies emit their corresponding Rust attributes.
use *;
;
Generated paths use ::core by default. #[error(import(path))] selects a different root.
use *;
;
Enum-wide generation options belong on the enum. Display, source, transparency, and conversion declarations belong on variants.
Code generation engine
fack-codegen is a regular no_std library rather than a proc-macro crate. Its supported API keeps compiler representations opaque while allowing downstream tools to choose staged or one-shot generation.
let target = input?;
let validated = target.validate?;
let tokens = validated.expand?;
let tokens = generate?;
Workspace
fackprovides the user-facing facadefack-coreprovides the blanket error capabilityfack-macroprovides the derive macro entry pointfack-codegenprovides the staged generation engine
License
GPL-3.0
Copyright (C) 2025 W. Frakchi
This program is free software. You can redistribute it and modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License or any later version.
See LICENSE.md for the full text.