diff --git a/misc/core-derive/src/lib.rs b/misc/core-derive/src/lib.rs index ad696f7b..0a423b18 100644 --- a/misc/core-derive/src/lib.rs +++ b/misc/core-derive/src/lib.rs @@ -112,7 +112,7 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream { additional.push(quote!{#substream_generic: ::libp2p::tokio_io::AsyncWrite}); if let Some(where_clause) = where_clause { - Some(quote!{#where_clause #(#additional),*}) + Some(quote!{#where_clause, #(#additional),*}) } else { Some(quote!{where #(#additional),*}) } diff --git a/misc/core-derive/tests/test.rs b/misc/core-derive/tests/test.rs index a041147d..0f90baf6 100644 --- a/misc/core-derive/tests/test.rs +++ b/misc/core-derive/tests/test.rs @@ -190,3 +190,24 @@ fn custom_event_and_polling() { require_net_behaviour::>(); } } + +#[test] +fn where_clause() { + #[allow(dead_code)] + #[derive(NetworkBehaviour)] + struct Foo where TSubstream: std::fmt::Debug { + ping: libp2p::ping::Ping, + } + + #[allow(dead_code)] + #[derive(NetworkBehaviour)] + struct Bar { + ping: libp2p::ping::Ping, + } + + #[allow(dead_code)] + #[derive(NetworkBehaviour)] + struct Qux where TSubstream: Clone { + ping: libp2p::ping::Ping, + } +}