File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff 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 )]
Original file line number Diff line number Diff line change 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)]
You can’t perform that action at this time.
0 commit comments