@@ -193,12 +193,15 @@ where
193
193
) -> Result < [ <Q :: ReadOnlyFetch as Fetch < ' w , ' s > >:: Item ; N ] , QueryEntityError > {
194
194
self . update_archetypes ( world) ;
195
195
196
- self . get_multiple_read_only_manual (
197
- world,
198
- entities,
199
- world. last_change_tick ( ) ,
200
- world. read_change_tick ( ) ,
201
- )
196
+ // SAFE: update_archetypes validates the `World` matches
197
+ unsafe {
198
+ self . get_multiple_read_only_manual (
199
+ world,
200
+ entities,
201
+ world. last_change_tick ( ) ,
202
+ world. read_change_tick ( ) ,
203
+ )
204
+ }
202
205
}
203
206
204
207
/// Gets the query result for the given [`World`] and [`Entity`].
@@ -360,7 +363,12 @@ where
360
363
361
364
/// Gets the read-only query results for the given [`World`] and array of [`Entity`], where the last change and
362
365
/// the current change tick are given.
363
- pub ( crate ) fn get_multiple_read_only_manual < ' s , ' w , const N : usize > (
366
+ ///
367
+ /// # Safety
368
+ ///
369
+ /// This must be called on the same `World` that the `Query` was generated from:
370
+ /// use `QueryState::validate_world` to verify this.
371
+ pub ( crate ) unsafe fn get_multiple_read_only_manual < ' s , ' w , const N : usize > (
364
372
& ' s self ,
365
373
world : & ' w World ,
366
374
entities : [ Entity ; N ] ,
@@ -370,16 +378,15 @@ where
370
378
self . validate_world ( world) ;
371
379
372
380
// SAFE: fetch is read-only
373
- let array_of_results = unsafe {
374
- entities. map ( |entity| {
375
- self . get_unchecked_manual :: < Q :: ReadOnlyFetch > (
376
- world,
377
- entity,
378
- last_change_tick,
379
- change_tick,
380
- )
381
- } )
382
- } ;
381
+ // and world must be validated
382
+ let array_of_results = entities. map ( |entity| {
383
+ self . get_unchecked_manual :: < Q :: ReadOnlyFetch > (
384
+ world,
385
+ entity,
386
+ last_change_tick,
387
+ change_tick,
388
+ )
389
+ } ) ;
383
390
384
391
// TODO: Replace with TryMap once https://github.com/rust-lang/rust/issues/79711 is stabilized
385
392
// If any of the get calls failed, bubble up the error
0 commit comments