Include #[diagnostic(forward(..)] in documentation

This commit is contained in:
Daniel Levin 2025-06-05 17:22:10 +02:00
parent 907857058d
commit 1e4ba14098
2 changed files with 22 additions and 0 deletions

View File

@ -211,6 +211,17 @@ pub enum MyLibError {
// Use `#[diagnostic(transparent)]` to wrap another [`Diagnostic`]. You won't see labels otherwise
#[diagnostic(transparent)]
AnotherError(#[from] AnotherError),
/// Forward the diagnostic to a particular field.
#[error("other error")]
#[diagnostic(forward(the_actual_diagnostic))]
EvenMoreData {
unrelated_field_1: String,
unrelated_field_2: usize,
#[source]
the_actual_diagnostic: AnotherError,
}
}
#[derive(Error, Diagnostic, Debug)]

View File

@ -211,6 +211,17 @@
//! // Use `#[diagnostic(transparent)]` to wrap another [`Diagnostic`]. You won't see labels otherwise
//! #[diagnostic(transparent)]
//! AnotherError(#[from] AnotherError),
//!
//! /// Forward the diagnostic to a particular field.
//! #[error("other error")]
//! #[diagnostic(forward(the_actual_diagnostic))]
//! EvenMoreData {
//! unrelated_field_1: String,
//! unrelated_field_2: usize,
//!
//! #[source]
//! the_actual_diagnostic: AnotherError,
//! }
//! }
//!
//! #[derive(Error, Diagnostic, Debug)]