Skip to content

Commit

Permalink
core-derive: use full qualified name when polling NetworkBehaviour (#…
Browse files Browse the repository at this point in the history
…1681)

* core-derive: use full qualified name when polling NetworkBehaviour

If the users define a custom poll method also named in `poll` like
`#[behaviour(poll_method = "poll")`, it will cause issues as the wrong
`poll` method being called.

So use full qualified name to avoid ambiguity.

Fixes #1679.

* Update changelog for patch release.

Co-authored-by: Max Inden <mail@max-inden.de>
Co-authored-by: Roman S. Borschel <roman@parity.io>
  • Loading branch information
3 people committed Jul 28, 2020
1 parent 9178459 commit 967f396
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions misc/core-derive/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.20.2 [2020-07-28]

- Generate fully-qualified method name for `poll` to avoid
ambiguity. [PR 1681](https://github.com/libp2p/rust-libp2p/pull/1681).

# 0.20.1 [2020-07-08]

- Allow users to opt out of the `NetworkBehaviourEventProcess`
Expand Down
2 changes: 1 addition & 1 deletion misc/core-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "libp2p-core-derive"
edition = "2018"
description = "Procedural macros of libp2p-core"
version = "0.20.1"
version = "0.20.2"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
2 changes: 1 addition & 1 deletion misc/core-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream {

Some(quote!{
loop {
match #field_name.poll(cx, poll_params) {
match #trait_to_impl::poll(&mut #field_name, cx, poll_params) {
#generate_event_match_arm
std::task::Poll::Ready(#network_behaviour_action::DialAddress { address }) => {
return std::task::Poll::Ready(#network_behaviour_action::DialAddress { address });
Expand Down

0 comments on commit 967f396

Please sign in to comment.