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

#[thread_local] statics shouldn't require Sync #18001

Closed
thestinger opened this issue Oct 13, 2014 · 6 comments
Closed

#[thread_local] statics shouldn't require Sync #18001

thestinger opened this issue Oct 13, 2014 · 6 comments
Labels
A-type-system Area: Type system

Comments

@thestinger
Copy link
Contributor

This was a recent regression.

@thestinger thestinger added the A-type-system Area: Type system label Oct 13, 2014
@emberian emberian added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Nov 12, 2014
@brson brson removed the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label May 28, 2015
@brson
Copy link
Contributor

brson commented May 28, 2015

I'm untagging all pre-1.0 regressions to repurpose it for stable regressions.

@brson
Copy link
Contributor

brson commented May 28, 2015

@alexcrichton Do you know if this is still a problem?

@alexcrichton
Copy link
Member

Yes this is still a problem:

#![feature(thread_local)]                

use std::cell::Cell;                     

#[thread_local]                          
pub static FOO: Cell<u32> = Cell::new(3);
foo.rs:5:29: 5:41 error: the trait `core::marker::Sync` is not implemented for the type `core::cell::UnsafeCell<u32>` [E0277]
foo.rs:5 pub static FOO: Cell<u32> = Cell::new(3);
                                     ^~~~~~~~~~~~
foo.rs:5:29: 5:41 note: `core::cell::UnsafeCell<u32>` cannot be shared between threads safely
foo.rs:5 pub static FOO: Cell<u32> = Cell::new(3);
                                     ^~~~~~~~~~~~
error: aborting due to previous error

@bltavares
Copy link
Contributor

Triaging: This still fails on rustc 1.9.0-nightly (c9629d61c 2016-03-10)

I've added the const_fn feature as well to reduce the warnings.

#![feature(const_fn)]
#![feature(thread_local)]                

use std::cell::Cell;                     

#[thread_local]                          
pub static FOO: Cell<u32> = Cell::new(3);

fn main() {}

Here is the produced error:

18001.rs:7:29: 7:41 error: the trait `core::marker::Sync` is not implemented for the type `core::cell::Cell<u32>` [E0277]
18001.rs:7 pub static FOO: Cell<u32> = Cell::new(3);
                                       ^~~~~~~~~~~~
18001.rs:7:29: 7:41 help: run `rustc --explain E0277` to see a detailed explanation
18001.rs:7:29: 7:41 note: `core::cell::Cell<u32>` cannot be shared between threads safely
18001.rs:7:29: 7:41 note: shared static variables must have a type that implements `Sync`
error: aborting due to previous error

@sorpaas
Copy link

sorpaas commented Oct 14, 2016

Any update on this?

@Mark-Simulacrum
Copy link
Member

Closing in favor of more-recent duplicate #35035.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system
Projects
None yet
Development

No branches or pull requests

7 participants