rust-lang / rust-lang/rust

2024 edition regression: cannot write blanket implementation for closures that return the Never type

Open
#139,610 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-edition-2024 F-never_type I-edition-triaged T-compiler T-edition T-types
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.