Skip to content

fix(bytesbuf_io): make ReadAsFuturesStream Send - #592

Merged
sandersaares merged 1 commit into
mainfrom
u/sasaares/bytesbuf-io-stream-send
Jul 22, 2026
Merged

fix(bytesbuf_io): make ReadAsFuturesStream Send#592
sandersaares merged 1 commit into
mainfrom
u/sasaares/bytesbuf-io-stream-send

Conversation

@sandersaares

Copy link
Copy Markdown
Member

[Copilot speaking]

ReadAsFuturesStream (returned by ReadExt::into_futures_stream()) was accidentally !Send. Its active_read field boxed the in-flight read future as a plain Pin<Box<dyn Future<...>>> with no + Send bound, and that single non-Send field made the whole stream !Send even when the underlying source is Send.

The future stored there comes from Read::read_any(), and the Read trait is declared with #[trait_variant::make(Send)] and documents that it "requires Send from both the implementation and any returned futures". So the future is always Send and the missing bound was purely an accidental omission.

This adds the + Send bound to the active_read field type and to the lifetime-extending transmute target types, plus a compile-time Send regression assertion (stream_is_send_when_source_is_send).

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
Copilot AI review requested due to automatic review settings July 21, 2026 06:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 + Send bound to the boxed in-flight read future (active_read), so it doesn’t force the whole stream to be !Send.
  • Updates the mem::transmute target/source trait-object types to preserve the Send bound while extending the lifetime.
  • Adds a compile-time regression test asserting the stream type is Send for a known-Send source (FakeRead).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.0%. Comparing base (701cfc0) to head (8dfd901).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #592   +/-   ##
=======================================
  Coverage   100.0%   100.0%           
=======================================
  Files         359      359           
  Lines       27901    27901           
=======================================
  Hits        27901    27901           
Flag Coverage Δ
linux 46.7% <100.0%> (-39.1%) ⬇️
linux-arm 46.7% <100.0%> (-40.1%) ⬇️
windows 46.7% <100.0%> (-40.5%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sandersaares
sandersaares added this pull request to the merge queue Jul 21, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 21, 2026
@sandersaares
sandersaares added this pull request to the merge queue Jul 21, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Jul 21, 2026
@sandersaares
sandersaares added this pull request to the merge queue Jul 21, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 21, 2026
@sandersaares
sandersaares added this pull request to the merge queue Jul 22, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Jul 22, 2026
@sandersaares
sandersaares merged commit 9e8115d into main Jul 22, 2026
52 checks passed
@sandersaares
sandersaares deleted the u/sasaares/bytesbuf-io-stream-send branch July 22, 2026 14:13
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.

6 participants