Skip to content

World queries borrow their context instead of keeping it (#179) - #180

Merged
nicolas-maman merged 1 commit into
mainfrom
fix-179
Oct 19, 2026
Merged

nicolas-maman merged 1 commit into
mainfrom
fix-179

Conversation

@nicolas-maman

Copy link
Copy Markdown
Collaborator

Closes #179.

The change

The six world queries no longer declare context: @keep ptr: cast_ray, cast_shape, cast_mover, overlap_aabb, overlap_shape and collide_mover.

None of them keeps the pointer. Each lends its local QueryRecorder to the internal query for the duration of the call.

The annotation was forced only by the helper query_recorder(context: @keep ptr), because it returned the context inside the struct. Now:

  • the helper builds the recorder with no context;
  • each query sets q.context on its own local;
  • Aether 0.830's narrowed E0902 (aether#2977) accepts that.

The general form, a parameter that flows into a result without being kept, is filed as aether#2990.

These keep their annotation, because each really stores the pointer:

  • set_custom_filter_callback
  • set_pre_solve_callback
  • set_user_data

Why it matters downstream

Siltreach's blade ray passes its own ragdoll, a borrowed pointer, in a @scoped context to cast_ray. Until now, @keep had to climb four of Siltreach's functions for a pointer nobody keeps.

Tests

  • test_physics_world gains borrowed_queries: a helper with a plain ptr context that forwards it through all six queries and counts the visits. It passes 260 of 260.
  • With @keep put back on cast_ray, the file fails to build with E0902, so the check guards against a regression.
  • The full gate is running locally on 0.830.

Pins

Aether 0.830.0 and aeb v0.327, both the latest releases.

cast_ray, cast_shape, cast_mover, overlap_aabb, overlap_shape and
collide_mover declared context: @keep ptr only because the helper
query_recorder took the context and returned it inside a QueryRecorder.
None of them keeps the pointer: each lends its local recorder to the
internal query for the call. The helper now builds the recorder without
a context, and each query sets q.context on its own local, which
Aether 0.830's narrowed E0902 accepts. Callers can pass a borrowed
pointer again, so Siltreach's blade ray no longer needs @keep climbing
four functions. The general form, a parameter that flows into a result
without being kept, is aether#2990.

test_physics_world forwards a plain borrowed ptr through all six
queries; with @keep back on any of them the file fails to build.
@nicolas-maman
nicolas-maman merged commit f0bd6d6 into main Oct 19, 2026
2 checks passed
@nicolas-maman
nicolas-maman deleted the fix-179 branch October 19, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

World queries declare context: @keep ptr only because query_recorder returns it in a struct

1 participant