Skip to content

Commit c155d51

Browse files
committed
Implement Send/Sync for CopyTaggedPtr
1 parent dc19dc2 commit c155d51

File tree

1 file changed

+20
-0
lines changed
  • compiler/rustc_data_structures/src/tagged_ptr

1 file changed

+20
-0
lines changed

compiler/rustc_data_structures/src/tagged_ptr/copy.rs

+20
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,26 @@ where
253253
}
254254
}
255255

256+
// Safety:
257+
// `CopyTaggedPtr<P, T, ..>` is semantically just `{ ptr: P, tag: T }`, as such
258+
// it's ok to implement `Sync` as long as `P: Sync, T: Sync`
259+
unsafe impl<P, T, const CP: bool> Sync for CopyTaggedPtr<P, T, CP>
260+
where
261+
P: Sync + Pointer,
262+
T: Sync + Tag,
263+
{
264+
}
265+
266+
// Safety:
267+
// `CopyTaggedPtr<P, T, ..>` is semantically just `{ ptr: P, tag: T }`, as such
268+
// it's ok to implement `Send` as long as `P: Send, T: Send`
269+
unsafe impl<P, T, const CP: bool> Send for CopyTaggedPtr<P, T, CP>
270+
where
271+
P: Send + Pointer,
272+
T: Send + Tag,
273+
{
274+
}
275+
256276
/// Test that `new` does not compile if there is not enough alignment for the
257277
/// tag in the pointer.
258278
///

0 commit comments

Comments
 (0)