From 8f322567b8baae557ba42295005ceb09301c88fd Mon Sep 17 00:00:00 2001 From: Gavrilikhin Daniil Date: Sun, 14 May 2023 19:09:06 +0800 Subject: [PATCH] Document `#[diagnostic(transparent)]` --- src/lib.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index cc113ce..20589ef 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -186,7 +186,7 @@ //! //! ```rust //! // lib/error.rs -//! use miette::Diagnostic; +//! use miette::{Diagnostic, SourceSpan}; //! use thiserror::Error; //! //! #[derive(Error, Diagnostic, Debug)] @@ -198,6 +198,18 @@ //! #[error("Oops it blew up")] //! #[diagnostic(code(my_lib::bad_code))] //! BadThingHappened, +//! +//! #[error(transparent)] +//! // Use `#[diagnostic(transparent)]` to wrap another [`Diagnostic`]. You won't see labels otherwise +//! #[diagnostic(transparent)] +//! AnotherError(#[from] AnotherError), +//! } +//! +//! #[derive(Error, Diagnostic, Debug)] +//! #[error("another error")] +//! pub struct AnotherError { +//! #[label("here")] +//! pub at: SourceSpan //! } //! ``` //!