Skip to content

add_startup_system_to_stage is broken #2246

@msklywenn

Description

@msklywenn

Bevy version

Tested 0.5.0 and main

Operating system & version

Windows 10

What you did

I tried adding a startup system to a custom stage. It panic'd.

use bevy::prelude::*;

#[derive(Debug, Hash, PartialEq, Eq, Clone, StageLabel)]
struct MyStage;

fn my_system() {
    println!("hello from my stage");
}

fn main() {
    App::build()
        .add_stage_after(CoreStage::Update, MyStage, SystemStage::single_threaded())
        .add_startup_system_to_stage(MyStage, my_system.system())
        .run();
}

What you expected to happen

my_system to be called normally.

What actually happened

$ RUST_BACKTRACE=1 cargo r
    Finished dev [unoptimized + debuginfo] target(s) in 0.36s
     Running `target\debug\stage_test.exe`
thread 'main' panicked at 'Stage 'MyStage' does not exist or is not a SystemStage', C:\Users\Daniel\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.5.0\src\schedule\mod.rs:150:17
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53\/library\std\src\panicking.rs:493
   1: std::panicking::begin_panic_fmt
             at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53\/library\std\src\panicking.rs:435
   2: bevy_ecs::schedule::{{impl}}::add_system_to_stage::{{closure}}<prout::MyStage,bevy_ecs::system::into_system::FunctionSystem<tuple<>, tuple<>, tuple<>, tuple<>, fn()>>
             at C:\Users\Daniel\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.5.0\src\schedule\mod.rs:150
   3: core::option::Option<mut bevy_ecs::schedule::stage::SystemStage*>::unwrap_or_else<mut bevy_ecs::schedule::stage::SystemStage*,closure-0>
             at C:\Users\Daniel\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\option.rs:427
   4: bevy_ecs::schedule::Schedule::add_system_to_stage<prout::MyStage,bevy_ecs::system::into_system::FunctionSystem<tuple<>, tuple<>, tuple<>, tuple<>, fn()>>
             at C:\Users\Daniel\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.5.0\src\schedule\mod.rs:147
   5: bevy_app::app_builder::{{impl}}::add_startup_system_to_stage::{{closure}}<prout::MyStage,bevy_ecs::system::into_system::FunctionSystem<tuple<>, tuple<>, tuple<>, tuple<>, fn()>>
             at C:\Users\Daniel\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_app-0.5.0\src\app_builder.rs:176
   6: bevy_ecs::schedule::Schedule::stage<bevy_ecs::schedule::Schedule,closure-0,bevy_app::CoreStage>
             at C:\Users\Daniel\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.5.0\src\schedule\mod.rs:177
   7: bevy_app::app_builder::AppBuilder::add_startup_system_to_stage<prout::MyStage,bevy_ecs::system::into_system::FunctionSystem<tuple<>, tuple<>, tuple<>, tuple<>, fn()>>
             at C:\Users\Daniel\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_app-0.5.0\src\app_builder.rs:173
   8: stage_test::main
             at .\src\main.rs:20
   9: core::ops::function::FnOnce::call_once<fn(),tuple<>>
             at C:\Users\Daniel\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:227
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Additional information

add_system_to_stage works fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorC-DocsAn addition or correction to our documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions