Required components should support caller tracking (track_caller).
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## What problem does this solve or what need does it fill?
Currently, when spawning an entity with a required component (e.g., via #[require(MyComponent)]), there is no built-in mechanism to automatically capture and pass the caller’s location (MaybeLocation) to that component. This becomes particularly problematic for generic components that are not intended to directly store MaybeLocation themselves, yet still need to track where they were created.
In such cases, the only way to obtain the creation location of a generic component—without knowing its concrete type—is to explicitly pass MaybeLocation during the spawn call. While workarounds like custom component hooks exist, they require significant boilerplate code and must be implemented for every component that needs location tracking.
## What solution would you like?
Extend the required component mechanism so that when an entity is spawned, the system automatically captures the caller’s location (via #[track_caller]) and injects it into any required component that supports MaybeLocation. This would eliminate the need for manual propagation and reduce repetitive code.
## What alternative(s) have you considered?
Manual MaybeLocation passing in each spawn call (cumbersome and error-prone).
Custom component hooks (requires extra code and per-component handling).
Neither alternative is as clean or maintainable as built-in automatic propagation.
(machine translation)
Contributor guide
Assessment
This issue has not been assessed yet.