Allow reborrowing Pin<&mut Self>

This commit is contained in:
Eric Holk 2024-09-19 17:23:46 -07:00
parent c22a4215a0
commit 97fbcf6773
No known key found for this signature in database
GPG key ID: F1A772BB658A63E1
4 changed files with 74 additions and 19 deletions

View file

@ -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() {}