bevy/crates/bevy_pbr/src/render
Boxy 024d98457c yeet unsound lifetime annotations on Query methods (#4243)
# Objective
Continuation of #2964 (I really should have checked other methods when I made that PR)

yeet unsound lifetime annotations on `Query` methods.
Example unsoundness:
```rust
use bevy::prelude::*;

fn main() {
    App::new().add_startup_system(bar).add_system(foo).run();
}

pub fn bar(mut cmds: Commands) {
    let e = cmds.spawn().insert(Foo { a: 10 }).id();
    cmds.insert_resource(e);
}

#[derive(Component, Debug, PartialEq, Eq)]
pub struct Foo {
    a: u32,
}
pub fn foo(mut query: Query<&mut Foo>, e: Res<Entity>) {
    dbg!("hi");
    {
        let data: &Foo = query.get(*e).unwrap();
        let data2: Mut<Foo> = query.get_mut(*e).unwrap();
        assert_eq!(data, &*data2); // oops UB
    }

    {
        let data: &Foo = query.single();
        let data2: Mut<Foo> = query.single_mut();
        assert_eq!(data, &*data2); // oops UB
    }

    {
        let data: &Foo = query.get_single().unwrap();
        let data2: Mut<Foo> = query.get_single_mut().unwrap();
        assert_eq!(data, &*data2); // oops UB
    }

    {
        let data: &Foo = query.iter().next().unwrap();
        let data2: Mut<Foo> = query.iter_mut().next().unwrap();
        assert_eq!(data, &*data2); // oops UB
    }

    {
        let mut opt_data: Option<&Foo> = None;
        let mut opt_data_2: Option<Mut<Foo>> = None;
        query.for_each(|data| opt_data = Some(data));
        query.for_each_mut(|data| opt_data_2 = Some(data));
        assert_eq!(opt_data.unwrap(), &*opt_data_2.unwrap()); // oops UB
    }
    dbg!("bye");
}

```

## Solution
yeet unsound lifetime annotations on `Query` methods

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2022-03-22 02:49:41 +00:00
..
depth.wgsl Update wgpu to 0.12 and naga to 0.8 (#3375) 2021-12-19 03:03:06 +00:00
light.rs Dynamic light clusters (#3968) 2022-03-08 04:56:42 +00:00
mesh.rs yeet unsound lifetime annotations on Query methods (#4243) 2022-03-22 02:49:41 +00:00
mesh.wgsl Replace old renderer with new renderer (#3312) 2021-12-14 03:58:23 +00:00
mesh_struct.wgsl Move import_path definitions into shader source (#3976) 2022-02-18 21:54:03 +00:00
mesh_view_bind_group.wgsl Move import_path definitions into shader source (#3976) 2022-02-18 21:54:03 +00:00
mod.rs Materials and MaterialPlugin (#3428) 2021-12-25 21:45:43 +00:00
pbr.wgsl KTX2/DDS/.basis compressed texture support (#3884) 2022-03-15 22:26:46 +00:00
wireframe.wgsl Replace old renderer with new renderer (#3312) 2021-12-14 03:58:23 +00:00