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.
Motivation
#2482: Dropping
DefaultGuard
in another thread doesn't cause it to get cleaned up properlyThe
Drop
impl ofDefaultGuard
modifies theCURRENT_STATE
thread local, assuming it to be the same thread local it was constructed with.However, because
DefaultGuard
isSend
, that may be a different thread local.Solution
As discussed in #2482, we should mark
DefaultGuard
as!Send
. This is a breaking API change.This PR is modeled after #1001, which does the same thing for
Entered
. One notable change is that I use a different trick for marking the struct as!Send
that doesn't involveunsafe
.Entered
currently uses:tracing/tracing/src/span.rs
Lines 1581 to 1591 in a0126b2
My PR proposes the following trick instead:
If accepted:
tracing/src/span.rs
that removes the use ofunsafe
to implement!Send
.