Open
Description
I tried this code:
use std::rc::Rc;
struct Unsendable(Rc<()>);
struct Sendable<T>(T);
unsafe impl<T> Send for Sendable<T> {}
impl<T> Sendable<T> {
#[inline(always)]
fn into_inner(self) -> T {
self.0
}
}
fn main() {
tokio::task::spawn({
let foo = Unsendable(Rc::new(()));
let foo = Sendable(foo);
async move {
let Sendable(foo) = foo;
// let foo = foo.into_inner();
}
});
}
If I replace line let Sendable(foo) = foo;
with let foo = foo.into_inner();
the error disappears.
I create bigger example, without tokio. Rust Playground
I expected to see successful compilation
Instead I got error[E0277]: Rc<()> cannot be sent between threads safely