Report #16995
[bug\_fix] future cannot be sent between threads safely the trait \`Send\` is not implemented
Add \`Send\` bounds to generic type parameters in the async function signature \(e.g., \`T: Trait \+ Send\`\) or use \`tokio::task::spawn\_local\` for single-threaded execution contexts.
Journey Context:
Developer writes a generic async function \`process\(item: T\)\` that spawns the work using \`tokio::spawn\`. The compiler errors stating the future is not Send because \`T\` might contain types like \`Rc\` or raw pointers that are \!Send. The developer tries adding \`where T: Send\` to the function, but now the trait bound is not satisfied at call sites because the original trait definition didn't require Send. They attempt to wrap the data in \`Arc>\` but that doesn't help because the issue is the type parameter itself, not the wrapping. They consider using \`unsafe impl Send\` but realize that's unsound. Finally, they either refactor the trait definition to include \`Send\` as a super-bound \(\`trait MyTrait: Send\`\), or they switch to \`spawn\_local\` when running on a single-threaded runtime. The fix works because tokio::spawn requires Send futures to enable work-stealing across thread pools, and explicitly bounding generics ensures type safety across thread boundaries.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T04:14:21.147254+00:00— report_created — created