Skip to content

Commit

Permalink
sdk-common: hack to avoid over-recursion when evaluating Send/Sync bo…
Browse files Browse the repository at this point in the history
…unds in rustc

See
#3749 (comment)
for the gory details.
  • Loading branch information
bnjbvr committed Aug 27, 2024
1 parent 4289d0d commit a83f6b6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions crates/matrix-sdk-base/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ experimental-sliding-sync = [
]
uniffi = ["dep:uniffi", "matrix-sdk-crypto?/uniffi", "matrix-sdk-common/uniffi"]

# Private feature, see
# https://github.com/matrix-org/matrix-rust-sdk/pull/3749#issuecomment-2312939823 for the gory
# details.
test-send-sync = []

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

Expand Down
17 changes: 17 additions & 0 deletions crates/matrix-sdk-base/src/rooms/normal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,23 @@ impl Room {
}
}

// See https://github.com/matrix-org/matrix-rust-sdk/pull/3749#issuecomment-2312939823.
#[cfg(not(feature = "test-send-sync"))]
unsafe impl Send for Room {}

// See https://github.com/matrix-org/matrix-rust-sdk/pull/3749#issuecomment-2312939823.
#[cfg(not(feature = "test-send-sync"))]
unsafe impl Sync for Room {}

#[cfg(feature = "test-send-sync")]
#[test]
// See https://github.com/matrix-org/matrix-rust-sdk/pull/3749#issuecomment-2312939823.
fn test_send_sync_for_room() {
fn assert_send_sync<T: Send + Sync>() {}

assert_send_sync::<Room>();
}

/// The underlying pure data structure for joined and left rooms.
///
/// Holds all the info needed to persist a room into the state store.
Expand Down
2 changes: 1 addition & 1 deletion xtask/src/ci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ fn run_wasm_checks(cmd: Option<WasmFeatureSet>) -> Result<()> {
WasmFeatureSet::MatrixSdkNoDefault,
"-p matrix-sdk --no-default-features --features js,rustls-tls",
),
(WasmFeatureSet::MatrixSdkBase, "-p matrix-sdk-base --features js"),
(WasmFeatureSet::MatrixSdkBase, "-p matrix-sdk-base --features js,test-send-sync"),
(WasmFeatureSet::MatrixSdkCommon, "-p matrix-sdk-common --features js"),
(
WasmFeatureSet::MatrixSdkIndexeddbStoresNoCrypto,
Expand Down

0 comments on commit a83f6b6

Please sign in to comment.