Allow reborrowing Pin<&mut Self>
This commit is contained in:
parent
c22a4215a0
commit
97fbcf6773
4 changed files with 74 additions and 19 deletions
|
|
@ -1,24 +1,34 @@
|
|||
//@ check-pass
|
||||
//@ignore-test
|
||||
|
||||
// Currently ignored due to self reborrowing not being implemented for Pin
|
||||
|
||||
#![feature(pin_ergonomics)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
use std::pin::Pin;
|
||||
|
||||
struct Foo;
|
||||
pub struct Foo;
|
||||
|
||||
impl Foo {
|
||||
fn foo(self: Pin<&mut Self>) {
|
||||
}
|
||||
|
||||
fn baz(self: Pin<&Self>) {
|
||||
}
|
||||
}
|
||||
|
||||
fn bar(x: Pin<&mut Foo>) {
|
||||
pub fn bar(x: Pin<&mut Foo>) {
|
||||
x.foo();
|
||||
x.foo(); // for this to work we need to automatically reborrow,
|
||||
// as if the user had written `x.as_mut().foo()`.
|
||||
|
||||
Foo::baz(x);
|
||||
|
||||
// FIXME: We should allow downgrading a Pin<&mut T> to Pin<&T>
|
||||
// x.baz();
|
||||
}
|
||||
|
||||
pub fn baaz(x: Pin<&Foo>) {
|
||||
x.baz();
|
||||
x.baz();
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue