Warning
This post was published 53 days ago. The information described in this article may have changed.
I'm running into something confusing that I'm still working on finding the root cause for. I can't do a playground demo because so far I've only been able to cause it by pulling in async_channel
.
struct TaskQueue {
// Commenting out this line fixes the issue.
new_tasks: async_channel::Receiver<()>,
pending: Vec<String>,
pending_temp: Vec<String>,
}
impl Future for TaskQueue {
type Output = ();
fn poll(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> Poll<Self::Output> {
let Self {
pending,
pending_temp,
..
} = &mut *self;
Poll::Pending
}
}
The error message:
error[E0596]: cannot borrow data in dereference of `Pin<&mut TaskQueue>` as mutable
--> leaf-protocol/src/lib.rs:256:13
|
256 | } = &mut *self;
| ^^^^^^^^^^ cannot borrow as mutable
|
= help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Pin<&mut TaskQueue>`
I'm confused as to what it is about Receiver
type that is somehow disabling the DerefMut
on Pin
for the whole struct. Receiver
isn't Sync
, but confusingly that isn't it because adding a raw pointer that is !Sync
and !Send
works just fine.
8 posts - 3 participants
🏷️ rust_feed