2024 edition regression: cannot write blanket implementation for closures that return the Never type
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
As laid out in the guide for the Never type fallback, closures which panic are now inferred to return !, rather than ().
In Bevy, we encountered this surprising breaking change in the form of https://github.com/bevyengine/bevy/issues/18778. While individual users can work around this by writing |my closure | -> () and explicitly specifying a return type or by using an ordinary function, we cannot work around this breakage ourselves by writing another blanket implementation because the Never type (!) is not available on stable Rust.
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 with the linked Rust 2024 Never type fallback guide and the Bevy issue describing the breakage. Investigate how closure return types and blanket implementations interact when a closure is inferred as !; done should be a documented or implemented resolution that preserves the intended stable-Rust use case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100