Closed
Description
use std::thread;
use std::sync::mpsc::channel;
fn main() {
let (tx, _rx) = channel();
thread::spawn(|| tx.send(()).unwrap());
}
Errors with:
<anon>:6:5: 6:18 error: the trait `core::marker::Sync` is not implemented for the type `core::cell::UnsafeCell<std::sync::mpsc::Flavor<()>>` [E0277]
<anon>:6 thread::spawn(|| tx.send(()).unwrap());
^~~~~~~~~~~~~
<anon>:6:5: 6:18 note: `core::cell::UnsafeCell<std::sync::mpsc::Flavor<()>>` cannot be shared between threads safely
<anon>:6 thread::spawn(|| tx.send(()).unwrap());
When the real solution here is to add the move
keyword to the closure, but the error message leaves everyone quite confused.