Skip to content

Observers, systems and commands that use closures and panic require explicit return type after Rust 2024 edition #18778

Closed
@Shatur

Description

@Shatur

Bevy version

v0.16.0-rc.3

[Optional] Relevant system information

Rust 1.86.0, 2024 edition.

What you did

fn test() {
    let mut app = App::new();
    app.add_observer(|_: Trigger<TestEvent>| {
        panic!();
    });
}

#[derive(Event)]
struct TestEvent;

What went wrong

The code no longer compiles, though it worked in Bevy 0.15.0 (which used the 2021 edition).

It also compiles when I explicitly specify the return type ():

fn test() {
    let mut app = App::new();
    app.add_observer(|_: Trigger<TestEvent>| -> () {
        panic!();
    });
}

#[derive(Event)]
struct TestEvent;

Metadata

Metadata

Labels

A-ECSEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorD-ComplexQuite challenging from either a design or technical perspective. Ask for help!P-Compile-FailureA failure to compile Bevy appsS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions