fix(bytesbuf_io): make ReadAsFuturesStream Send - #592
Merged
Conversation
The active_read field boxed the in-flight read future as a plain dyn Future without a Send bound, making ReadAsFuturesStream !Send even for Send sources. The Read trait requires Send from both the implementation and any returned futures, so the omitted bound was accidental. Add the + Send bound to the field and the lifetime transmute, plus a compile-time Send regression assertion. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5dc0fa30-2509-41e9-8f92-5f8de05ef04b
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the bytesbuf_io ReadExt::into_futures_stream() adapter so the returned ReadAsFuturesStream is Send when the underlying Read source is Send, aligning the adapter with the Read trait’s documented “all returned futures are Send” contract.
Changes:
- Adds a missing
+ Sendbound to the boxed in-flight read future (active_read), so it doesn’t force the whole stream to be!Send. - Updates the
mem::transmutetarget/source trait-object types to preserve theSendbound while extending the lifetime. - Adds a compile-time regression test asserting the stream type is
Sendfor a known-Sendsource (FakeRead).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #592 +/- ##
=======================================
Coverage 100.0% 100.0%
=======================================
Files 359 359
Lines 27901 27901
=======================================
Hits 27901 27901
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
sgalkin
approved these changes
Jul 21, 2026
Vaiz
approved these changes
Jul 21, 2026
martin-kolinek
approved these changes
Jul 21, 2026
sandersaares
added this pull request to the merge queue
Jul 21, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Jul 21, 2026
ralfbiedert
approved these changes
Jul 21, 2026
sandersaares
added this pull request to the merge queue
Jul 21, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to no response for status checks
Jul 21, 2026
sandersaares
added this pull request to the merge queue
Jul 21, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Jul 21, 2026
sandersaares
added this pull request to the merge queue
Jul 22, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to no response for status checks
Jul 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[Copilot speaking]
ReadAsFuturesStream(returned byReadExt::into_futures_stream()) was accidentally!Send. Itsactive_readfield boxed the in-flight read future as a plainPin<Box<dyn Future<...>>>with no+ Sendbound, and that single non-Sendfield made the whole stream!Sendeven when the underlying source isSend.The future stored there comes from
Read::read_any(), and theReadtrait is declared with#[trait_variant::make(Send)]and documents that it "requiresSendfrom both the implementation and any returned futures". So the future is alwaysSendand the missing bound was purely an accidental omission.This adds the
+ Sendbound to theactive_readfield type and to the lifetime-extendingtransmutetarget types, plus a compile-timeSendregression assertion (stream_is_send_when_source_is_send).