Skip to content

Commit c8d214d

Browse files
authored
Add #[track_caller] to Query methods (#12984)
# Objective - Closes #12958 ## Solution - Find all methods under `Query` that mention panicking, and add `#[track_caller]` to them. --- ## Changelog - Added `#[track_caller]` to `Query::many`, `Query::many_mut`, `Query::transmute_lens`, and `Query::transmute_lens_filtered`. ## For reviewers I'm unfamiliar with the depths of the `Query` struct. Please check whether it makes since for the updated methods to have `#[track_caller]`, and if I missed any!
1 parent 538d699 commit c8d214d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

crates/bevy_ecs/src/system/query.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> Query<'w, 's, D, F> {
922922
///
923923
/// - [`get_many`](Self::get_many) for the non-panicking version.
924924
#[inline]
925+
#[track_caller]
925926
pub fn many<const N: usize>(&self, entities: [Entity; N]) -> [ROQueryItem<'_, D>; N] {
926927
match self.get_many(entities) {
927928
Ok(items) => items,
@@ -1038,6 +1039,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> Query<'w, 's, D, F> {
10381039
/// - [`get_many_mut`](Self::get_many_mut) for the non panicking version.
10391040
/// - [`many`](Self::many) to get read-only query items.
10401041
#[inline]
1042+
#[track_caller]
10411043
pub fn many_mut<const N: usize>(&mut self, entities: [Entity; N]) -> [D::Item<'_>; N] {
10421044
match self.get_many_mut(entities) {
10431045
Ok(items) => items,
@@ -1351,6 +1353,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> Query<'w, 's, D, F> {
13511353
///
13521354
/// [`EntityLocation`]: crate::entity::EntityLocation
13531355
/// [`&Archetype`]: crate::archetype::Archetype
1356+
#[track_caller]
13541357
pub fn transmute_lens<NewD: QueryData>(&mut self) -> QueryLens<'_, NewD> {
13551358
self.transmute_lens_filtered::<NewD, ()>()
13561359
}
@@ -1361,6 +1364,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> Query<'w, 's, D, F> {
13611364
/// additional archetypal query terms like [`With`](crate::query::With) and [`Without`](crate::query::Without)
13621365
/// will not necessarily be respected and non-archetypal terms like [`Added`](crate::query::Added) and
13631366
/// [`Changed`](crate::query::Changed) will only be respected if they are in the type signature.
1367+
#[track_caller]
13641368
pub fn transmute_lens_filtered<NewD: QueryData, NewF: QueryFilter>(
13651369
&mut self,
13661370
) -> QueryLens<'_, NewD, NewF> {

0 commit comments

Comments
 (0)