error[E0502]: cannot borrow `query` as mutable because it is also borrowed as immutable
  --> tests/ui/query_lifetime_safety.rs:17:39
   |
16 |             let data: &Foo = query.get(e).unwrap();
   |                              ------------ immutable borrow occurs here
17 |             let mut data2: Mut<Foo> = query.get_mut(e).unwrap();
   |                                       ^^^^^^^^^^^^^^^^ mutable borrow occurs here
18 |             assert_eq!(data, &mut *data2); // oops UB
   |             ----------------------------- immutable borrow later used here

error[E0502]: cannot borrow `query` as immutable because it is also borrowed as mutable
  --> tests/ui/query_lifetime_safety.rs:23:30
   |
22 |             let mut data2: Mut<Foo> = query.get_mut(e).unwrap();
   |                                       ---------------- mutable borrow occurs here
23 |             let data: &Foo = query.get(e).unwrap();
   |                              ^^^^^^^^^^^^ immutable borrow occurs here
24 |             assert_eq!(data, &mut *data2); // oops UB
   |                                    ----- mutable borrow later used here

error[E0502]: cannot borrow `query` as mutable because it is also borrowed as immutable
  --> tests/ui/query_lifetime_safety.rs:29:39
   |
28 |             let data: &Foo = query.get_component::<Foo>(e).unwrap();
   |                              ----------------------------- immutable borrow occurs here
29 |             let mut data2: Mut<Foo> = query.get_component_mut(e).unwrap();
   |                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
30 |             assert_eq!(data, &mut *data2); // oops UB
   |             ----------------------------- immutable borrow later used here

error[E0502]: cannot borrow `query` as immutable because it is also borrowed as mutable
  --> tests/ui/query_lifetime_safety.rs:35:30
   |
34 |             let mut data2: Mut<Foo> = query.get_component_mut(e).unwrap();
   |                                       -------------------------- mutable borrow occurs here
35 |             let data: &Foo = query.get_component::<Foo>(e).unwrap();
   |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ immutable borrow occurs here
36 |             assert_eq!(data, &mut *data2); // oops UB
   |                                    ----- mutable borrow later used here

error[E0502]: cannot borrow `query` as mutable because it is also borrowed as immutable
  --> tests/ui/query_lifetime_safety.rs:41:39
   |
40 |             let data: &Foo = query.single();
   |                              -------------- immutable borrow occurs here
41 |             let mut data2: Mut<Foo> = query.single_mut();
   |                                       ^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
42 |             assert_eq!(data, &mut *data2); // oops UB
   |             ----------------------------- immutable borrow later used here

error[E0502]: cannot borrow `query` as immutable because it is also borrowed as mutable
  --> tests/ui/query_lifetime_safety.rs:47:30
   |
46 |             let mut data2: Mut<Foo> = query.single_mut();
   |                                       ------------------ mutable borrow occurs here
47 |             let data: &Foo = query.single();
   |                              ^^^^^^^^^^^^^^ immutable borrow occurs here
48 |             assert_eq!(data, &mut *data2); // oops UB
   |                                    ----- mutable borrow later used here

error[E0502]: cannot borrow `query` as mutable because it is also borrowed as immutable
  --> tests/ui/query_lifetime_safety.rs:53:39
   |
52 |             let data: &Foo = query.get_single().unwrap();
   |                              ------------------ immutable borrow occurs here
53 |             let mut data2: Mut<Foo> = query.get_single_mut().unwrap();
   |                                       ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
54 |             assert_eq!(data, &mut *data2); // oops UB
   |             ----------------------------- immutable borrow later used here

error[E0502]: cannot borrow `query` as immutable because it is also borrowed as mutable
  --> tests/ui/query_lifetime_safety.rs:59:30
   |
58 |             let mut data2: Mut<Foo> = query.get_single_mut().unwrap();
   |                                       ---------------------- mutable borrow occurs here
59 |             let data: &Foo = query.get_single().unwrap();
   |                              ^^^^^^^^^^^^^^^^^^ immutable borrow occurs here
60 |             assert_eq!(data, &mut *data2); // oops UB
   |                                    ----- mutable borrow later used here

error[E0502]: cannot borrow `query` as mutable because it is also borrowed as immutable
  --> tests/ui/query_lifetime_safety.rs:65:39
   |
64 |             let data: &Foo = query.iter().next().unwrap();
   |                              ------------ immutable borrow occurs here
65 |             let mut data2: Mut<Foo> = query.iter_mut().next().unwrap();
   |                                       ^^^^^^^^^^^^^^^^ mutable borrow occurs here
66 |             assert_eq!(data, &mut *data2); // oops UB
   |             ----------------------------- immutable borrow later used here

error[E0502]: cannot borrow `query` as immutable because it is also borrowed as mutable
  --> tests/ui/query_lifetime_safety.rs:71:30
   |
70 |             let mut data2: Mut<Foo> = query.iter_mut().next().unwrap();
   |                                       ---------------- mutable borrow occurs here
71 |             let data: &Foo = query.iter().next().unwrap();
   |                              ^^^^^^^^^^^^ immutable borrow occurs here
72 |             assert_eq!(data, &mut *data2); // oops UB
   |                                    ----- mutable borrow later used here

error[E0502]: cannot borrow `query` as mutable because it is also borrowed as immutable
  --> tests/ui/query_lifetime_safety.rs:79:13
   |
78 |             query.for_each(|data| opt_data = Some(data));
   |             -------------------------------------------- immutable borrow occurs here
79 |             query.for_each_mut(|data| opt_data_2 = Some(data));
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
80 |             assert_eq!(opt_data.unwrap(), &mut *opt_data_2.unwrap()); // oops UB
   |                        -------- immutable borrow later used here

error[E0502]: cannot borrow `query` as immutable because it is also borrowed as mutable
  --> tests/ui/query_lifetime_safety.rs:87:13
   |
86 |             query.for_each_mut(|data| opt_data_2 = Some(data));
   |             -------------------------------------------------- mutable borrow occurs here
87 |             query.for_each(|data| opt_data = Some(data));
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ immutable borrow occurs here
88 |             assert_eq!(opt_data.unwrap(), &mut *opt_data_2.unwrap()); // oops UB
   |                                                 ---------- mutable borrow later used here
