Skip to content

Commit 1f563c9

Browse files
committed
task: add manual Sync impl for VerificationCache to avoid overflowing evaluation requirements
1 parent 9a9730d commit 1f563c9

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

crates/matrix-sdk-base/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ uniffi = ["dep:uniffi", "matrix-sdk-crypto?/uniffi", "matrix-sdk-common/uniffi"]
3030
# Private feature, see
3131
# https://github.com/matrix-org/matrix-rust-sdk/pull/3749#issuecomment-2312939823 for the gory
3232
# details.
33-
test-send-sync = []
33+
test-send-sync = ["matrix-sdk-crypto?/test-send-sync"]
3434

3535
# "message-ids" feature doesn't do anything and is deprecated.
3636
message-ids = []

crates/matrix-sdk-crypto/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ experimental-algorithms = []
2323
uniffi = ["dep:uniffi"]
2424
_disable-minimum-rotation-period-ms = []
2525

26+
# Private feature, see
27+
# https://github.com/matrix-org/matrix-rust-sdk/pull/3749#issuecomment-2312939823 for the gory
28+
# details.
29+
test-send-sync = []
30+
2631
# "message-ids" feature doesn't do anything and is deprecated.
2732
message-ids = []
2833

crates/matrix-sdk-crypto/src/verification/cache.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ pub struct VerificationCache {
3333
inner: Arc<VerificationCacheInner>,
3434
}
3535

36+
// See https://github.com/matrix-org/matrix-rust-sdk/pull/3749#issuecomment-2312939823.
37+
#[cfg(not(feature = "test-send-sync"))]
38+
unsafe impl Sync for VerificationCache {}
39+
40+
#[cfg(feature = "test-send-sync")]
41+
#[test]
42+
// See https://github.com/matrix-org/matrix-rust-sdk/pull/3749#issuecomment-2312939823.
43+
fn test_send_sync_for_room() {
44+
fn assert_send_sync<T: Send + Sync>() {}
45+
46+
assert_send_sync::<VerificationCache>();
47+
}
48+
3649
#[derive(Debug, Default)]
3750
struct VerificationCacheInner {
3851
verification: StdRwLock<BTreeMap<OwnedUserId, BTreeMap<String, Verification>>>,

0 commit comments

Comments
 (0)