diff --git a/misc/core-derive/src/lib.rs b/misc/core-derive/src/lib.rs index 0a423b18..79a551a5 100644 --- a/misc/core-derive/src/lib.rs +++ b/misc/core-derive/src/lib.rs @@ -112,7 +112,11 @@ 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),*}) + if where_clause.predicates.trailing_punct() { + Some(quote!{#where_clause #(#additional),*}) + } else { + 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 0f90baf6..98073e94 100644 --- a/misc/core-derive/tests/test.rs +++ b/misc/core-derive/tests/test.rs @@ -205,6 +205,12 @@ fn where_clause() { ping: libp2p::ping::Ping, } + #[allow(dead_code)] + #[derive(NetworkBehaviour)] + struct Baz where TSubstream: std::fmt::Debug + Clone, { + ping: libp2p::ping::Ping, + } + #[allow(dead_code)] #[derive(NetworkBehaviour)] struct Qux where TSubstream: Clone {