From 35cabffe39d17b30cfce92ac4b6d06d6c09ca8c6 Mon Sep 17 00:00:00 2001 From: ShryukGrandhi <85529990+ShryukGrandhi@users.noreply.github.com> Date: Wed, 21 Oct 2026 22:34:06 -0700 Subject: [PATCH] fix(error): use core::error::Error and core::fmt in error module Signed-off-by: ShryukGrandhi <85529990+ShryukGrandhi@users.noreply.github.com> --- src/error/mod.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/error/mod.rs b/src/error/mod.rs index 0a23dd04..23784c71 100644 --- a/src/error/mod.rs +++ b/src/error/mod.rs @@ -1,6 +1,6 @@ //! # Custom warnings and errors -use std::error::Error; -use std::fmt; +use core::error::Error; +use core::fmt; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -254,4 +254,13 @@ mod tests { // ensure it can be used as a trait object let _: &dyn Error = &e; } + + #[test] + fn failed_implements_core_error() { + // Failed must not depend on std for its Error impl (no-std, #413) + let e = Failed::predict("boom"); + let err: &dyn core::error::Error = &e; + assert_eq!(err.to_string(), "Predict failed: boom"); + assert!(err.source().is_none()); + } }