Skip to content

Commit

Permalink
Add test with generic transparent field
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Sep 5, 2021
1 parent e95b4ad commit 42d36e5
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/test_generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,23 @@ fn test_display_enum_compound() {
assert_eq!(format!("{}", instance), "DebugOnly");
}

// Should expand to:
//
// impl<E> Display for EnumTransparentGeneric<E>
// where
// E: Display;
//
// impl<E> Error for EnumTransparentGeneric<E>
// where
// E: Error,
// Self: Debug + Display;
//
#[derive(Error, Debug)]
pub enum EnumTransparentGeneric<E> {
#[error(transparent)]
Other(E),
}

// Should expand to:
//
// impl<E> Display for StructDebugGeneric<E>
Expand Down Expand Up @@ -127,3 +144,18 @@ pub struct StructFromGeneric<E> {
#[from]
pub source: StructDebugGeneric<E>,
}

// Should expand to:
//
// impl<E> Display for StructTransparentGeneric<E>
// where
// E: Display;
//
// impl<E> Error for StructTransparentGeneric<E>
// where
// E: Error,
// Self: Debug + Display;
//
#[derive(Error, Debug)]
#[error(transparent)]
pub struct StructTransparentGeneric<E>(E);

0 comments on commit 42d36e5

Please sign in to comment.