swarm-derive/lib: Don't clone error on inject_dial_failure (#2349)

`NetworkBehaviour::inject_dial_failure` expects a reference for the error, thus
the error should not be cloned when passing it to the inner behaviours in the
`NetworkBehaviour` derivation.

Fixes Issue #2348.
This commit is contained in:
Elena Frank
2021-11-18 13:21:12 +01:00
committed by GitHub
parent 4bd44c812a
commit 17d6b4ba67
5 changed files with 16 additions and 5 deletions

View File

@ -276,10 +276,10 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream {
let inject = match field.ident {
Some(ref i) => {
quote! { self.#i.inject_dial_failure(peer_id, handler, error.clone()) }
quote! { self.#i.inject_dial_failure(peer_id, handler, error) }
}
None => {
quote! { self.#enum_n.inject_dial_failure(peer_id, handler, error.clone()) }
quote! { self.#enum_n.inject_dial_failure(peer_id, handler, error) }
}
};