-
-
Notifications
You must be signed in to change notification settings - Fork 36
Closed
Labels
A-pin-projectionArea: #[pin_project]Area: #[pin_project]C-bugCategory: related to a bug.Category: related to a bug.regression-from-0.3-to-0.4Regression from 0.3 to 0.4Regression from 0.3 to 0.4
Milestone
Description
Caused by #47.
Such code is used a lot in futures etc., so I would like to support it...
However, I'm not sure if this can be fixed by ways other than changing self
argument to self: Pin<&mut Self>
.
Code:
use std::pin::Pin;
#[pin_project::pin_project]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
impl<T, U> Struct<T, U> {
fn get_pin_mut<'a>(mut self: Pin<&'a mut Self>) -> Pin<&'a mut T> {
self.project().pinned
}
}
Error:
error[E0515]: cannot return value referencing function parameter `self`
--> src/lib.rs:33:9
|
33 | self.project().pinned
| ----^^^^^^^^^^^^^^^^^
| |
| returns a value referencing data owned by the current function
| `self` is borrowed here
Related: rust-lang/rust#54934
Metadata
Metadata
Assignees
Labels
A-pin-projectionArea: #[pin_project]Area: #[pin_project]C-bugCategory: related to a bug.Category: related to a bug.regression-from-0.3-to-0.4Regression from 0.3 to 0.4Regression from 0.3 to 0.4