docs: Include #[diagnostic(forward(..)] in documentation (#446)

This commit is contained in:
Daniel Levin 2025-09-26 06:11:28 +02:00 committed by GitHub
parent 907857058d
commit 51ca022b1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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)]