Add compiletest for enum error types

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2022-05-13 08:06:00 +02:00
parent 0a4cf4ad24
commit 0b32574d5b
1 changed files with 19 additions and 0 deletions

View File

@ -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,
},
}