Skip to content

epoch: Fix defer_destroy doc example about not requiring T: Send#1288

Open
teddytennant wants to merge 1 commit into
crossbeam-rs:mainfrom
teddytennant:epoch-defer-destroy-send-doc
Open

epoch: Fix defer_destroy doc example about not requiring T: Send#1288
teddytennant wants to merge 1 commit into
crossbeam-rs:mainfrom
teddytennant:epoch-defer-destroy-send-doc

Conversation

@teddytennant

Copy link
Copy Markdown
Contributor

What

Replaces the doc example in Guard::defer_destroy that motivates the lack of a T: Send bound, and turns it from an ignore block into a compiling doctest.

Fixes #1253.

Why

The old snippet was copied from defer_unchecked and doesn't actually demonstrate the point: it defers destruction of an i32, which is Send, so it would compile fine even if defer_destroy required T: Send. The comment "Shared is not Send!" is beside the point, since the bound in question is on T, not on Shared<'_, 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 not Send, so such a Node isn'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 guard in crossbeam-epoch — 13 passed (including the new defer_destroy doctest)
  • cargo fmt --check -p crossbeam-epoch — clean

Copilot AI review requested due to automatic review settings July 11, 2026 12:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

The documentation example about T: Send not being required for Guard::defer_destroy does not apply to the function

2 participants