-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Open
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.
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
Metadata
Metadata
Assignees
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.