Skip to content

Commit 1e4ba14

Browse files
committed
Include #[diagnostic(forward(..)] in documentation
1 parent 9078570 commit 1e4ba14

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,17 @@ pub enum MyLibError {
211211
// Use `#[diagnostic(transparent)]` to wrap another [`Diagnostic`]. You won't see labels otherwise
212212
#[diagnostic(transparent)]
213213
AnotherError(#[from] AnotherError),
214+
215+
/// Forward the diagnostic to a particular field.
216+
#[error("other error")]
217+
#[diagnostic(forward(the_actual_diagnostic))]
218+
EvenMoreData {
219+
unrelated_field_1: String,
220+
unrelated_field_2: usize,
221+
222+
#[source]
223+
the_actual_diagnostic: AnotherError,
224+
}
214225
}
215226

216227
#[derive(Error, Diagnostic, Debug)]

src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,17 @@
211211
//! // Use `#[diagnostic(transparent)]` to wrap another [`Diagnostic`]. You won't see labels otherwise
212212
//! #[diagnostic(transparent)]
213213
//! AnotherError(#[from] AnotherError),
214+
//!
215+
//! /// Forward the diagnostic to a particular field.
216+
//! #[error("other error")]
217+
//! #[diagnostic(forward(the_actual_diagnostic))]
218+
//! EvenMoreData {
219+
//! unrelated_field_1: String,
220+
//! unrelated_field_2: usize,
221+
//!
222+
//! #[source]
223+
//! the_actual_diagnostic: AnotherError,
224+
//! }
214225
//! }
215226
//!
216227
//! #[derive(Error, Diagnostic, Debug)]

0 commit comments

Comments
 (0)