Skip to content

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

Open
@alice-i-cecile

Description

@alice-i-cecile

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 bevyengine/bevy#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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-edition-2024Area: The 2024 editionF-never_type`#![feature(never_type)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-editionRelevant to the edition team.T-typesRelevant to the types team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions