Skip to content

Nondescriptive panic message during resource_scope #5365

@jakobhellermann

Description

@jakobhellermann

Bevy version

bevy main

What you did

When inserting the resource removed in resource_scope during the callback

use bevy_ecs::prelude::*;

struct Resource {}

fn main() {
    let mut world = World::new();
    world.insert_resource(Resource {});
    world.resource_scope(|world, _res: Mut<Resource>| {
        world.insert_resource(Resource {});
    });
}

bevy panics with an unhelpful message of

thread 'main' panicked at 'assertion failed: !self.contains_resource::<R>()', /home/jakob/.cargo/registry/src/index.crates.io-e139d0d48fed7772/bevy_ecs-0.7.0/src/world/mod.rs:1072:9

What went wrong

It would be nice to show more information, something like resource repro::Resource was inserted during call to resource_scope, which is not allowed because ....

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorD-TrivialNice and easy! A great choice to get started with Bevy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions