S0058: Shared handle cannot be stored in state
Generated from rellum-diagnostics/src/db.rs.
Explanation
Shared[T] handles are tick-scoped aliases created so Move values can be read by multiple consumers within one tick. Storing a Shared[T] handle in ~ state would let it outlive the tick that created it, which would make later ticks read an invalid handle.
Common causes
- using share(value) as a ~ state initial value
- returning share(value) from a feedback clause
- annotating state as Shared[T]
Canonical fixes
- store the owned value or a Copy projection instead of the Shared handle
Before:
history ~ feedback(
on line => share(line),
share("")
)
After:
history ~ feedback(
on line => line,
""
)
- create Shared[T] handles only at the use sites within the same tick
Code example
history ~ feedback(
on line => share(line),
share("")
)