From 04b07c4d14a0a6ec350fc21261a33d859fc71289 Mon Sep 17 00:00:00 2001 From: folex <0xdxdy@gmail.com> Date: Tue, 27 Sep 2022 13:27:32 +0400 Subject: [PATCH] swarm-derive: Specify `NetworkBehaviour` by full path (#2932) Co-authored-by: Thomas Eizinger Co-authored-by: Max Inden --- swarm-derive/CHANGELOG.md | 2 ++ swarm-derive/src/lib.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/swarm-derive/CHANGELOG.md b/swarm-derive/CHANGELOG.md index 464bec7fe95..0c64fd352da 100644 --- a/swarm-derive/CHANGELOG.md +++ b/swarm-derive/CHANGELOG.md @@ -2,8 +2,10 @@ - Fix an issue where the derive would generate bad code if the type parameters between the behaviour and a custom out event differed. See [PR 2907]. +- Fix an issue where the derive would generate incorrect code depending on available imports. See [PR 2921]. [PR 2907]: https://github.com/libp2p/rust-libp2p/pull/2907 +[PR 2921]: https://github.com/libp2p/rust-libp2p/pull/2921 # 0.30.0 diff --git a/swarm-derive/src/lib.rs b/swarm-derive/src/lib.rs index 6899ba7d79d..426e4faec1f 100644 --- a/swarm-derive/src/lib.rs +++ b/swarm-derive/src/lib.rs @@ -125,7 +125,7 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream { ) .unwrap(); let ty = &field.ty; - quote! {#variant(<#ty as NetworkBehaviour>::OutEvent)} + quote! {#variant(<#ty as #trait_to_impl>::OutEvent)} }) .collect::>(); let visibility = &ast.vis;