diff options
| author | Maybe Waffle <waffle.lapkin@gmail.com> | 2023-04-13 16:45:07 +0000 |
|---|---|---|
| committer | Maybe Waffle <waffle.lapkin@gmail.com> | 2023-04-13 16:51:04 +0000 |
| commit | c155d5149fe49736cfb5b24eaa1c854b836019f3 (patch) | |
| tree | 9bbd69a0d96996e1485e67b787a3b5ef67ca8ea1 /compiler/rustc_data_structures/src | |
| parent | dc19dc29c9c384d2285a2a659111d670483562bb (diff) | |
| download | rust-c155d5149fe49736cfb5b24eaa1c854b836019f3.tar.gz rust-c155d5149fe49736cfb5b24eaa1c854b836019f3.zip | |
Implement `Send`/`Sync` for `CopyTaggedPtr`
Diffstat (limited to 'compiler/rustc_data_structures/src')
| -rw-r--r-- | compiler/rustc_data_structures/src/tagged_ptr/copy.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/compiler/rustc_data_structures/src/tagged_ptr/copy.rs b/compiler/rustc_data_structures/src/tagged_ptr/copy.rs index 02dcbd389df..68d660f48b4 100644 --- a/compiler/rustc_data_structures/src/tagged_ptr/copy.rs +++ b/compiler/rustc_data_structures/src/tagged_ptr/copy.rs @@ -253,6 +253,26 @@ where } } +// Safety: +// `CopyTaggedPtr<P, T, ..>` is semantically just `{ ptr: P, tag: T }`, as such +// it's ok to implement `Sync` as long as `P: Sync, T: Sync` +unsafe impl<P, T, const CP: bool> Sync for CopyTaggedPtr<P, T, CP> +where + P: Sync + Pointer, + T: Sync + Tag, +{ +} + +// Safety: +// `CopyTaggedPtr<P, T, ..>` is semantically just `{ ptr: P, tag: T }`, as such +// it's ok to implement `Send` as long as `P: Send, T: Send` +unsafe impl<P, T, const CP: bool> Send for CopyTaggedPtr<P, T, CP> +where + P: Send + Pointer, + T: Send + Tag, +{ +} + /// Test that `new` does not compile if there is not enough alignment for the /// tag in the pointer. /// |
