diff --git a/swarm-derive/src/lib.rs b/swarm-derive/src/lib.rs index 2ac9f978657..51305e38190 100644 --- a/swarm-derive/src/lib.rs +++ b/swarm-derive/src/lib.rs @@ -159,6 +159,7 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream { let visibility = &ast.vis; Some(quote! { + #[derive(::std::fmt::Debug)] #visibility enum #name #impl_generics #where_clause { diff --git a/swarm-derive/tests/test.rs b/swarm-derive/tests/test.rs index d23dd8ed863..f4a313198a9 100644 --- a/swarm-derive/tests/test.rs +++ b/swarm-derive/tests/test.rs @@ -21,6 +21,7 @@ use futures::prelude::*; use libp2p::swarm::{NetworkBehaviour, SwarmEvent}; use libp2p_swarm_derive::*; +use std::fmt::Debug; /// Small utility to check that a type implements `NetworkBehaviour`. #[allow(dead_code)] @@ -275,7 +276,10 @@ fn custom_event_mismatching_field_names() { fn bound() { #[allow(dead_code)] #[derive(NetworkBehaviour)] - struct Foo { + struct Foo + where + ::OutEvent: Debug, + { ping: libp2p::ping::Ping, bar: T, } @@ -288,6 +292,7 @@ fn where_clause() { struct Foo where T: Copy + NetworkBehaviour, + ::OutEvent: Debug, { ping: libp2p::ping::Ping, bar: T, @@ -489,3 +494,21 @@ fn event_process() { }; } } + +#[test] +fn generated_out_event_derive_debug() { + #[allow(dead_code)] + #[derive(NetworkBehaviour)] + struct Foo { + ping: libp2p::ping::Ping, + } + + fn require_debug() + where + T: NetworkBehaviour, + ::OutEvent: Debug, + { + } + + require_debug::(); +}