Skip to content

Commit 92b2019

Browse files
Add Send + Sync + Unpin bound to PrimitiveAtom::Impl
This is not a breaking change as the trait is sealed. The `Impl` associated type was `doc(hidden)` before as no one should care about it. That changed when we needed a `const` way to create `Atomic`. This change is useful as the whether `Atomic` implements `Send`, `Sync` and `Unpin` currently depends on the `Impl` type. That's inconvenient. `Atomic` should always implement `Send`, `Sync` and `Unpin`, so the bound was added.
1 parent bcdf4ed commit 92b2019

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/impls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ mod sealed {
2424
/// the public API -- see the module docs.
2525
pub trait PrimitiveAtom: Sized + Copy + sealed::Sealed {
2626
/// The standard library type that is the atomic version of `Self`.
27-
type Impl;
27+
type Impl: Send + Sync + Unpin;
2828

2929
#[doc(hidden)]
3030
fn into_impl(self) -> Self::Impl;

src/tests.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,3 +263,9 @@ gen_tests_for_opt_non_zeroes!(nz_u64, NonZeroU64);
263263
gen_tests_for_opt_non_zeroes!(nz_i64, NonZeroI64);
264264
gen_tests_for_opt_non_zeroes!(nz_usize, NonZeroUsize);
265265
gen_tests_for_opt_non_zeroes!(nz_isize, NonZeroIsize);
266+
267+
fn _atomic_is_always_send_sync<T: Atom>(a: Atomic<T>) {
268+
fn requires_send_sync<X: Send + Sync>(_: X) {}
269+
270+
requires_send_sync(a);
271+
}

0 commit comments

Comments
 (0)