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: Add Sync bound to ScopedKey (fixes #25894) #25897

Closed

Conversation

Manishearth
Copy link
Member

I have no clue what I'm doing. Someone should verify that this is
the necessary/sufficient fix to #25894 before merging 😛

@rust-highfive
Copy link
Collaborator

r? @aturon

(rust_highfive has picked a reviewer for you, use r? to override)

@Manishearth Manishearth force-pushed the scoped_strikes_again branch from bddced1 to cd558a3 Compare May 30, 2015 09:14
@Manishearth
Copy link
Member Author

Running it on the original testcase gives us

test.rs:11:18: 11:24 error: the trait `core::marker::Sync` is not implemented for the type `alloc::rc::Rc<u8>` [E0277]
test.rs:11      let guard = scoped(|| {
                            ^~~~~~
note: in expansion of closure expansion
test.rs:9:22: 32:3 note: expansion site
test.rs:11:18: 11:24 note: `alloc::rc::Rc<u8>` cannot be shared between threads safely
test.rs:11      let guard = scoped(|| {
                            ^~~~~~
note: in expansion of closure expansion
test.rs:9:22: 32:3 note: expansion site
error: aborting due to previous error

which is what we wanted

@Manishearth
Copy link
Member Author

This breaks the cell_allowed() test in the same file.

On that note, I'm skeptical as to why Cell should be allowed here in the first place. But I haven't figured out this API properly yet.

/home/manishearth/Mozilla/rust/src/libstd/thread/scoped_tls.rs:75:13: 75:44 error: the trait `core::marker::Sync` is not implemented for the type `core::cell::UnsafeCell<u32>` [E0277]
/home/manishearth/Mozilla/rust/src/libstd/thread/scoped_tls.rs:75             ::std::thread::ScopedKey::new();
                                                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/manishearth/Mozilla/rust/src/libstd/thread/scoped_tls.rs:66:1: 87:2 note: in expansion of scoped_thread_local!
/home/manishearth/Mozilla/rust/src/libstd/thread/scoped_tls.rs:262:9: 262:53 note: expansion site
/home/manishearth/Mozilla/rust/src/libstd/thread/scoped_tls.rs:75:13: 75:44 note: `core::cell::UnsafeCell<u32>` cannot be shared between threads safely
/home/manishearth/Mozilla/rust/src/libstd/thread/scoped_tls.rs:75             ::std::thread::ScopedKey::new();
                                                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/manishearth/Mozilla/rust/src/libstd/thread/scoped_tls.rs:66:1: 87:2 note: in expansion of scoped_thread_local!
/home/manishearth/Mozilla/rust/src/libstd/thread/scoped_tls.rs:262:9: 262:53 note: expansion site
rustc: x86_64-unknown-linux-gnu/stage1/test/rbmltest-x86_64-unknown-linux-gnu
rustc: x86_64-unknown-linux-gnu/stage1/test/alloctest-x86_64-unknown-linux-gnu
/home/manishearth/Mozilla/rust/src/liballoc/lib.rs:82:12: 82:18 warning: unused or unknown feature, #[warn(unused_features)] on by default
/home/manishearth/Mozilla/rust/src/liballoc/lib.rs:82 #![feature(unique)]

@alexcrichton
Copy link
Member

I don't think this is what we want as one of the major uses of thread-local storage is non-Sync data. This API is unstable so there's no huge sense of urgency to fix it, so I'm going to close this in favor of discussion on #25894 instead.

@Manishearth Manishearth deleted the scoped_strikes_again branch September 3, 2015 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants