Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kawadakk opened this issue Aug 1, 2022 · 3 comments · Fixed by #100023
Closed

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

kawadakk opened this issue Aug 1, 2022 · 3 comments · Fixed by #100023
Assignees
Labels
C-bug Category: This is a bug. P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@kawadakk
Copy link
Contributor

kawadakk commented Aug 1, 2022

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

@kawadakk kawadakk added the C-bug Category: This is a bug. label Aug 1, 2022
@lcnr
Copy link
Contributor

lcnr commented Aug 1, 2022

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,
{
}

@lcnr lcnr added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Aug 1, 2022
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Aug 1, 2022
@saethlin
Copy link
Member

saethlin commented Aug 1, 2022

@rustbot claim

@apiraino
Copy link
Contributor

apiraino commented Aug 3, 2022

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-high

@rustbot rustbot added P-high High priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Aug 3, 2022
@bors bors closed this as completed in 04f72f9 Aug 3, 2022
workingjubilee pushed a commit to tcdi/postgrestd that referenced this issue Sep 15, 2022
Add back Send and Sync impls on ChunksMut iterators

Fixes rust-lang/rust#100014

These were accidentally removed in #94247 because the representation was changed from `&mut [T]` to `*mut T`, which has `!Send + !Sync`.
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this issue Apr 20, 2024
Add back Send and Sync impls on ChunksMut iterators

Fixes rust-lang/rust#100014

These were accidentally removed in #94247 because the representation was changed from `&mut [T]` to `*mut T`, which has `!Send + !Sync`.
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this issue Apr 27, 2024
Add back Send and Sync impls on ChunksMut iterators

Fixes rust-lang/rust#100014

These were accidentally removed in #94247 because the representation was changed from `&mut [T]` to `*mut T`, which has `!Send + !Sync`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants