epoch: Fix defer_destroy doc example about not requiring T: Send#1288
Open
teddytennant wants to merge 1 commit into
Open
epoch: Fix defer_destroy doc example about not requiring T: Send#1288teddytennant wants to merge 1 commit into
teddytennant wants to merge 1 commit into
Conversation
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.
What
Replaces the doc example in
Guard::defer_destroythat motivates the lack of aT: Sendbound, and turns it from anignoreblock into a compiling doctest.Fixes #1253.
Why
The old snippet was copied from
defer_uncheckedand doesn't actually demonstrate the point: it defers destruction of ani32, which isSend, so it would compile fine even ifdefer_destroyrequiredT: Send. The comment "Sharedis notSend!" is beside the point, since the bound in question is onT, not onShared<'_, T>.The new example shows the actual typical case where the type system can't prove
T: Send: a concurrent data structure node containing a raw pointer to another node. Raw pointers are notSend, so such aNodeisn't either, yet deferring its destruction is fine because the destructor only runs after the grace period, when the object is no longer shared. The surrounding prose is updated to match.Testing
The example is now a real doctest instead of
ignore, so it's compiled and run by CI.cargo test --doc guardincrossbeam-epoch— 13 passed (including the newdefer_destroydoctest)cargo fmt --check -p crossbeam-epoch— clean