Skip to content

slice::Chunks[Exact]Mut are no longer Send + Sync after #94247 #100014

Closed

Description

I tried this code (Playground):

struct AssertChunksExactMutPropagatesSend
where
    std::slice::ChunksExactMut<'static, std::cell::Cell<u32>>: Send;
struct AssertChunksExactMutPropagatesSync
where
    std::slice::ChunksExactMut<'static, std::sync::MutexGuard<'static, u32>>: Sync;

I expected to see this happen: Successful compilation (as it does in 1.62.1)

Instead, this happened:

error[E0277]: `*mut [Cell<u32>]` cannot be sent between threads safely
 --> src/lib.rs:3:5
  |
3 |     std::slice::ChunksExactMut<'static, std::cell::Cell<u32>>: Send;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*mut [Cell<u32>]` cannot be sent between threads safely
  |
  = help: within `ChunksExactMut<'static, Cell<u32>>`, the trait `Send` is not implemented for `*mut [Cell<u32>]`
  = note: required because it appears within the type `ChunksExactMut<'static, Cell<u32>>`
  = help: see issue #48214
  = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable

error[E0277]: `*mut [MutexGuard<'static, u32>]` cannot be shared between threads safely
 --> src/lib.rs:6:5
  |
6 |     std::slice::ChunksExactMut<'static, std::sync::MutexGuard<'static, u32>>: Sync;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*mut [MutexGuard<'static, u32>]` cannot be shared between threads safely
  |
  = help: within `ChunksExactMut<'static, MutexGuard<'static, u32>>`, the trait `Sync` is not implemented for `*mut [MutexGuard<'static, u32>]`
  = note: required because it appears within the type `ChunksExactMut<'static, MutexGuard<'static, u32>>`
  = help: see issue #48214
  = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable

For more information about this error, try `rustc --explain E0277`.

Meta

rustc --version --verbose:

rustc 1.64.0-nightly (f9cba6374 2022-07-31)
binary: rustc
commit-hash: f9cba63746d0fff816250b2ba7b706b5d4dcf000
commit-date: 2022-07-31
host: x86_64-unknown-linux-gnu
release: 1.64.0-nightly
LLVM version: 14.0.6

The problem doesn't occur with nightly-2022-07-27 (pre-#94247).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

C-bugCategory: This is a bug.P-highHigh priorityT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions