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
mark register_info, register_contributed_bundle_info unsafe (#20790)
# Objective
calling `register_info` and `register_contributed_bundle_info` with
incorrect arguments results in panics in 100% safe code
part of breaking up #20739
## Solution
Mark `register_info` and `register_contributed_bundle_info` as unsafe.
## Testing
cargo test in crates/bevy_ecs
---
It's pretty obvious why this is unsafe, but the function doesn't
explicitly forbid it:
```rust
fn safe_bundle_register_world_unsafety() {
#![forbid(unsafe_code)]
let mut world = World::new();
let mut antiworld = World::new();
#[derive(crate::prelude::Component, Debug, PartialEq, Eq)]
struct A(u32);
let mut world_components = world.components_registrator();
let _ = antiworld
.bundles
.register_info::<(A,)>(&mut world_components, &mut antiworld.storages);
// unsound beyond this point
let e = antiworld.spawn((A(3),));
let a = e.get::<A>().unwrap();
assert_eq!(a, &A(3));
}
```
0 commit comments