bevy/crates/bevy_ecs/src
Boxy a1a07945d6 fix some memory leaks detected by miri (#4959)
The first leak:
```rust
    #[test]
    fn blob_vec_drop_empty_capacity() {
        let item_layout = Layout:🆕:<Foo>();
        let drop = drop_ptr::<Foo>;
        let _ = unsafe { BlobVec::new(item_layout, Some(drop), 0) };
    }
```
this is because we allocate the swap scratch in blobvec regardless of what the capacity is, but we only deallocate if capacity is > 0

The second leak:
```rust
    #[test]
    fn panic_while_overwriting_component() {
        let helper = DropTestHelper::new();

        let res = panic::catch_unwind(|| {
            let mut world = World::new();
            world
                .spawn()
                .insert(helper.make_component(true, 0))
                .insert(helper.make_component(false, 1));

            println!("Done inserting! Dropping world...");
        });

        let drop_log = helper.finish(res);

        assert_eq!(
            &*drop_log,
            [
                DropLogItem::Create(0),
                DropLogItem::Create(1),
                DropLogItem::Drop(0),
            ]
        );
    }
```
this is caused by us not running the drop impl on the to-be-inserted component if the drop impl of the overwritten component panics

---

managed to figure out where the leaks were by using this 10/10 command
```
cargo --quiet test --lib -- --list | sed 's/: test$//' | MIRIFLAGS="-Zmiri-disable-isolation" xargs -n1 cargo miri test --lib -- --exact
```
which runs every test one by one rather than all at once which let miri actually tell me which test had the leak 🙃
2022-07-01 21:54:28 +00:00
..
entity Improve entity and component API docs (#4767) 2022-06-21 15:29:22 +00:00
query fix new clippy lints (#5160) 2022-07-01 13:41:23 +00:00
schedule remove unnecessary unsafe impl of Send+Sync for ParallelSystemContainer (#5137) 2022-06-29 15:44:33 +00:00
storage fix some memory leaks detected by miri (#4959) 2022-07-01 21:54:28 +00:00
system Add ability to inspect entity's components (#5136) 2022-06-30 15:23:09 +00:00
world fix some memory leaks detected by miri (#4959) 2022-07-01 21:54:28 +00:00
archetype.rs Mark mutable APIs under ECS storage as pub(crate) (#5065) 2022-06-21 20:35:26 +00:00
bundle.rs Add comparison methods to FilteredAccessSet (#4211) 2022-05-09 14:39:22 +00:00
change_detection.rs untyped APIs for components and resources (#4447) 2022-05-30 15:32:47 +00:00
component.rs Derive default for enums where possible (#5158) 2022-07-01 03:42:15 +00:00
event.rs Fix Events example link (#5126) 2022-06-28 16:37:36 +00:00
lib.rs Add global init and get accessors for all newtyped TaskPools (#2250) 2022-06-09 02:43:24 +00:00
reflect.rs bevy_reflect: put serialize into external ReflectSerialize type (#4782) 2022-06-20 17:18:58 +00:00