Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(swarm-derive): use full path for std result in derive macros #5839

Merged
merged 8 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ libp2p-request-response = { version = "0.28.1", path = "protocols/request-respon
libp2p-server = { version = "0.12.6", path = "misc/server" }
libp2p-stream = { version = "0.3.0-alpha", path = "protocols/stream" }
libp2p-swarm = { version = "0.46.0", path = "swarm" }
libp2p-swarm-derive = { version = "=0.35.0", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required.
libp2p-swarm-derive = { version = "=0.35.1", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required.
libp2p-swarm-test = { version = "0.5.0", path = "swarm-test" }
libp2p-tcp = { version = "0.43.0", path = "transports/tcp" }
libp2p-tls = { version = "0.6.0", path = "transports/tls" }
Expand Down
5 changes: 5 additions & 0 deletions swarm-derive/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.35.1

- Fix `NetworkBehaviour` derive macro: replace the `Result` with `std::result::Result`.
See [PR 4568](https://github.com/libp2p/rust-libp2p/pull/5839)

## 0.35.0

- Implement refactored `Transport`.
Expand Down
2 changes: 1 addition & 1 deletion swarm-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-swarm-derive"
edition = "2021"
rust-version = { workspace = true }
description = "Procedural macros of libp2p-swarm"
version = "0.35.0"
version = "0.35.1"
authors = ["Parity Technologies <[email protected]>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
10 changes: 5 additions & 5 deletions swarm-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> syn::Result<Toke
}

impl #impl_generics ::core::fmt::Debug for #enum_name #ty_generics #where_clause_debug {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
match &self {
#(#enum_name::#match_variants(event) => {
write!(f, "{}: {:?}", #enum_name_str, event)
Expand Down Expand Up @@ -426,7 +426,7 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> syn::Result<Toke
connection_id: #connection_id,
local_addr: &#multiaddr,
remote_addr: &#multiaddr,
) -> Result<(), #connection_denied> {
) -> std::result::Result<(), #connection_denied> {
#(#handle_pending_inbound_connection_stmts)*

Ok(())
Expand All @@ -439,7 +439,7 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> syn::Result<Toke
peer: #peer_id,
local_addr: &#multiaddr,
remote_addr: &#multiaddr,
) -> Result<#t_handler<Self>, #connection_denied> {
) -> std::result::Result<#t_handler<Self>, #connection_denied> {
Ok(#handle_established_inbound_connection)
}

Expand All @@ -450,7 +450,7 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> syn::Result<Toke
maybe_peer: Option<#peer_id>,
addresses: &[#multiaddr],
effective_role: #endpoint,
) -> Result<::std::vec::Vec<#multiaddr>, #connection_denied> {
) -> std::result::Result<::std::vec::Vec<#multiaddr>, #connection_denied> {
#handle_pending_outbound_connection
}

Expand All @@ -462,7 +462,7 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> syn::Result<Toke
addr: &#multiaddr,
role_override: #endpoint,
port_use: #port_use,
) -> Result<#t_handler<Self>, #connection_denied> {
) -> std::result::Result<#t_handler<Self>, #connection_denied> {
Ok(#handle_established_outbound_connection)
}

Expand Down
Loading