aboutsummaryrefslogtreecommitdiff
path: root/tests/test_transparent.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_transparent.rs')
-rw-r--r--tests/test_transparent.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test_transparent.rs b/tests/test_transparent.rs
index b862b25..84d7c91 100644
--- a/tests/test_transparent.rs
+++ b/tests/test_transparent.rs
@@ -57,3 +57,24 @@ fn test_anyhow() {
assert_eq!("outer", error.to_string());
assert_eq!("inner", error.source().unwrap().to_string());
}
+
+#[test]
+fn test_non_static() {
+ #[derive(Error, Debug)]
+ #[error(transparent)]
+ struct Error<'a> {
+ inner: ErrorKind<'a>,
+ }
+
+ #[derive(Error, Debug)]
+ enum ErrorKind<'a> {
+ #[error("unexpected token: {:?}", token)]
+ Unexpected { token: &'a str },
+ }
+
+ let error = Error {
+ inner: ErrorKind::Unexpected { token: "error" },
+ };
+ assert_eq!("unexpected token: \"error\"", error.to_string());
+ assert!(error.source().is_none());
+}