fix(diagnostics): bound formatting and release ingress before callbacks

Bound UTF-8 formatting and release diagnostic ingress before invoking
callbacks. Check error-ID collisions at Rust/C++ release final link.

Validation: diagnostic tests, strict Clippy, Miri and final-link cases.
This commit is contained in:
Onur Özkan committed 2026-11-07 18:12:11 +03:00
1 parent 3226ef97fe
commit 84807dde4e
12 files changed
+547 -48

No files matched your search

@@ -1,4 +1,4 @@
//! Attribute expansion for `kaptan-err-reportable`.
//! Error derive and reporting-attribute expansion for `kaptan-err-reportable`.
use proc_macro::TokenStream;
use quote::{format_ident, quote};
@@ -12,8 +12,12 @@ use syn::{
/// [`core::error::Error`] for an explicitly numbered error enum.
///
/// Every variant must declare a stable nonzero
/// `#[kaptan_error(id = ...)]`. Duplicate IDs fail compilation within an enum
/// or crate and fail final linking when they originate in different crates.
/// `#[kaptan_error(id = ...)]`. The derive rejects duplicates within an enum.
/// Across enums, duplicate IDs emit the same reserved symbol. Collision detection
/// requires both defining objects to participate in compilation or final linking.
/// Unextracted archive members are not checked, so catalog allocation still needs
/// review. The fixture guide in `tests/final_link.md` describes Rust release-LTO
/// and native Linux checks. Embedded linker combinations need their own checks.
#[proc_macro_derive(KaptanError, attributes(kaptan_error))]
pub fn derive_kaptan_error(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput);