From 0b32574d5bbbc302ddfe2dc914d97874c0acd2f9 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 13 May 2022 08:06:00 +0200 Subject: [PATCH] Add compiletest for enum error types Signed-off-by: Matthias Beyer --- tests/test_diagnostic_source_macro.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/test_diagnostic_source_macro.rs b/tests/test_diagnostic_source_macro.rs index d7c5d2d..ad52845 100644 --- a/tests/test_diagnostic_source_macro.rs +++ b/tests/test_diagnostic_source_macro.rs @@ -18,3 +18,22 @@ fn test_diagnostic_source() { }; assert!(error.diagnostic_source().is_some()); } + +// Compiletest this: +#[derive(thiserror::Error, miette::Diagnostic, Debug)] +enum EnumError { + #[error("Some Error text")] + SyntaxErr(#[from] AnErr), +} + +// Compiletest this: +#[derive(thiserror::Error, miette::Diagnostic, Debug)] +enum AnotherEnumError { + #[error("Some other Error Text")] + SyntaxErr { + #[from] + #[source] + #[diagnostic_source] + source: AnErr, + }, +}