From 42d36e5806a6e6c5b80fba823cbb48df6025db82 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 4 Sep 2021 18:21:29 -0700 Subject: [PATCH] Add test with generic transparent field --- tests/test_generics.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/test_generics.rs b/tests/test_generics.rs index 1297c76..f5e1de2 100644 --- a/tests/test_generics.rs +++ b/tests/test_generics.rs @@ -99,6 +99,23 @@ fn test_display_enum_compound() { assert_eq!(format!("{}", instance), "DebugOnly"); } +// Should expand to: +// +// impl Display for EnumTransparentGeneric +// where +// E: Display; +// +// impl Error for EnumTransparentGeneric +// where +// E: Error, +// Self: Debug + Display; +// +#[derive(Error, Debug)] +pub enum EnumTransparentGeneric { + #[error(transparent)] + Other(E), +} + // Should expand to: // // impl Display for StructDebugGeneric @@ -127,3 +144,18 @@ pub struct StructFromGeneric { #[from] pub source: StructDebugGeneric, } + +// Should expand to: +// +// impl Display for StructTransparentGeneric +// where +// E: Display; +// +// impl Error for StructTransparentGeneric +// where +// E: Error, +// Self: Debug + Display; +// +#[derive(Error, Debug)] +#[error(transparent)] +pub struct StructTransparentGeneric(E);