Description
Edit: simplified reproducer as well as workaround available at #72477 (comment)
Hello,
While trying to implement an AsyncRead wrapper, I have hit something that I think is the borrow-checker being too restrictive with &mut
inside Pin
.
I originally thought it was an issue in pin-project
, but @taiki-e pointed out that the issue also happens with raw Pin
, in taiki-e/pin-project#226 (comment) (thank you!)
Copying the example here (with an explicit lifetime):
pub struct Foo<'a> {
buf: &'a mut [u8],
}
impl<'a> Foo<'a> {
fn foo<'b>(self: std::pin::Pin<&'b mut Self>) {
self.buf = &mut self.buf[1..];
}
}
This is potentially related to #54934 ; but seeing as it manifests in a completely different way (ie. it doesn't manifest with just &
references in the original example with pin-project linked above, though the example code here is incorrect indeed), I thought it'd be better to open another issue, as at worst it'd be fixed at the same time as #54934 and would just add another test.
As usual, thank you for all you do on this great language!