Bound stream Send impls on the handle's Target, not the handle - #134
Open
cf-rhett wants to merge 1 commit into
Open
Bound stream Send impls on the handle's Target, not the handle#134cf-rhett wants to merge 1 commit into
cf-rhett wants to merge 1 commit into
Conversation
`StreamProducer`, `StreamConsumer`, `StreamGrantW`, and `StreamGrantR` all store `Q::Target`, but their `Send` impls required `Q: Send`. `BbqHandle` is a public safe trait with an associated `Target`, so a downstream impl can pair a `Send` handle with a `!Send` target and hand back a `Send` producer that holds an `Rc`. `Q: Send` says nothing about `Q::Target`, and nothing else in the crate closes that gap. The producer and consumer hold nothing but `Q::Target`, so they need no manual impl at all; the derived one is already exactly right. The two grants also hold a `NonNull`, so they keep an unsafe impl, now bounded on `Q::Target: Send` the way `FramedGrantW` and `FramedGrantR` already are.
cf-rhett
marked this pull request as ready for review
July 31, 2026 19:34
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.
Summary
The four stream types all store
Q::Target, but theirSendimpls were written againstQ:BbqHandleis a public, unsealed, safe trait with an associatedTarget, so a downstream impl is free to pair aSendhandle with a!Sendtarget.Q: Sendthen says nothing about the thing actually being stored, and you get aSendproducer holding anRc.framed.rsalready gets this right —FramedGrantWandFramedGrantRare bounded onQ::Target: Send— so the two modules disagreed on the same question.StreamProducerandStreamConsumerhold nothing butQ::Target. They never needed a manual impl; the derived one is already exactly right, so this deletes them.StreamGrantWandStreamGrantRalso hold aNonNull, so they keep an unsafe impl, now bounded onQ::Target: Sendto matchframed.rs.Only in-tree
BbqHandleimpls are&BBQueueandArc<BBQueue>, both of which usetype Target = Self— so nothing in the crate or its tests changes behavior, and the full matrix below still passes.Reproducer
A purely safe downstream impl was enough to forge the bad bound. Against
mainthis compiles and passes; with this change it fails to compile withRc<BBQueue<..>> cannot be sent between threads safely.I left this out of the tree since catching it needs a compile-fail harness (
trybuild) that the crate does not currently pull in. Happy to add it if you would like the coverage.Testing
cargo test --features=stdcargo build --no-default-featurescargo build --features=stdcargo build --no-default-features --target=thumbv6m-none-eabicargo build --target=thumbv6m-none-eabi --features=portable-atomic-unsafe-assume-single-core./miri.shNote on my other open PRs
Independent of #132 and #133 in substance. #133 merges with this cleanly. #132 collides textually only — it appends a test module directly below the
StreamGrantRimpl this rewrites, so whichever lands second wants a keep-both resolution rather than a semantic one.