Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion library/alloc/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,11 @@ impl<T, A: Allocator> Arc<T, A> {
#[inline]
#[stable(feature = "arc_unique", since = "1.4.0")]
pub fn try_unwrap(this: Self) -> Result<T, Self> {
if this.inner().strong.compare_exchange(1, 0, Relaxed, Relaxed).is_err() {
// This `Acquire` synchronizes with the `Release` in the `Arc::drop`
// of the penultimate `Arc`, allowing the resulting value to contain
// all modifications that may have happened due to that copy of the
// `Arc`.
if this.inner().strong.compare_exchange(1, 0, Acquire, Relaxed).is_err() {
Copy link
Contributor

@tmiasko tmiasko Jan 5, 2026

Choose a reason for hiding this comment

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

Did you perhaps missed the fact that the success path already contains acquire fence?

Copy link
Member Author

Choose a reason for hiding this comment

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

I did, yes! Thank you.

return Err(this);
}

Expand Down
Loading