You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#[test]fnunsound_disjoint_mutable_access(){fnunsound_system(mutquery:Query<(Entity,&mutTestComponent)>,refs:Query<super::EntityRef,Without<TestComponent>>,){let(id,mut c) = query.iter_mut().next().unwrap();let world = refs.iter().next().unwrap().world();// We now have mutable and shared access to the same component at the same time.let c2 = world.entity(id).get::<TestComponent>().unwrap();*c = TestComponent(1);println!("{c2:?}");}letmut world = World::new();
world.spawn(TestComponent(0));
world.spawn_empty();letmut schedule = Schedule::new();
schedule.add_systems(unsound_system);
schedule.run(&mut world);}
What went wrong
This should panic at runtime since the accesses of the two system params conflict. Instead, it runs and allows aliased mutable access.
Activity
james7132 commentedon Aug 12, 2023
EntityRef::worldwas supposed to be removed in #6960 to make this impossible. Apparently it wasn't. Probably the result of a bad merge or rebase.joseph-gio commentedon Aug 16, 2023
Ah, looks like it snuck back in during this merge: 0c91c16
Allow disjoint mutable world access via `EntityMut` (#9419)
Allow disjoint mutable world access via `EntityMut` (bevyengine#9419)