derive(NetworkBehaviour) triggers unreachable_code on nightly when ToSwarm is uninhabited
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.6k
- Forks
- 1.3k
- Avg merge
- 8h 47m
- Merged PRs (30d)
- 19
Description
Summary
With -D warnings #[derive(NetworkBehaviour)] fails to compile if any field's ToSwarm is uninhabited (e.g. connection_limits::Behaviour where ToSwarm = Infallible). Recent nightly now lints unreachable call.
Expected behavior
Generated unreachable code should have #[allow(unreachable_code)]
Actual behavior
error: unreachable call
--> src/behaviour.rs:12:10
| #[derive(NetworkBehaviour)]
| ^^^^^^^^^^^^^^^^ unreachable call
= note: `-D unreachable-code` implied by `-D warnings`
= note: this error originates in the derive macro `NetworkBehaviour`
Relevant log output
Possible Solution
Suggested fix: have libp2p-swarm-derive emit #[allow(unreachable_code)] on the generated conversion/poll code.
Workaround: #[allow(unreachable_code)] at the derive site downstream.
Version
libp2p 0.56, rustc 1.100.0-nightly
Would you like to work on fixing this bug?
Maybe
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the libp2p-swarm-derive crate and inspect the generated conversion and poll code for NetworkBehaviour. Reproduce the derive with connection_limits::Behaviour, whose ToSwarm is Infallible, under -D warnings; done means the generated code compiles without an unreachable-code error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100