Skip to content

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

Closed

Description

@kawadakk

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).

Activity

  1. lcnr commented on Aug 1, 2022

    @lcnr
    Contributor
    use std::cell::Cell;
    use std::sync::MutexGuard;
    use std::slice::{ChunksExactMut, ChunksMut};
    
    fn foo()
    where
        ChunksMut<'static, Cell<i32>>: Send,
        ChunksMut<'static, MutexGuard<'static, u32>>: Sync,
        ChunksExactMut<'static, Cell<i32>>: Send,
        ChunksExactMut<'static, MutexGuard<'static, u32>>: Sync,
    {
    }
  2. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Aug 1, 2022
  3. saethlin commented on Aug 1, 2022

    @saethlin
    Member

    @rustbot claim

  4. added a commit that references this issue on Aug 3, 2022
  5. apiraino commented on Aug 3, 2022

    @apiraino
    Contributor

    WG-prioritization assigning priority (Zulip discussion).

    @rustbot label -I-prioritize +P-high

  6. added
    P-highHigh priority
    and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.P-highHigh priorityT-libs-api[DEPRECATED; DO NOT USE]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