2024-09-04 16:03:47 -07:00
|
|
|
//@ check-pass
|
|
|
|
|
|
|
|
#![feature(pin_ergonomics)]
|
|
|
|
#![allow(dead_code, incomplete_features)]
|
|
|
|
|
|
|
|
use std::pin::Pin;
|
|
|
|
|
|
|
|
struct Foo;
|
|
|
|
|
|
|
|
impl Foo {
|
|
|
|
fn baz(self: Pin<&mut Self>) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn foo(_: Pin<&mut Foo>) {
|
|
|
|
}
|
|
|
|
|
2024-09-19 16:27:09 -07:00
|
|
|
fn foo_const(_: Pin<&Foo>) {
|
|
|
|
}
|
|
|
|
|
2024-09-19 15:29:01 -07:00
|
|
|
fn bar(x: Pin<&mut Foo>) {
|
2024-09-04 16:03:47 -07:00
|
|
|
foo(x);
|
|
|
|
foo(x); // for this to work we need to automatically reborrow,
|
|
|
|
// as if the user had written `foo(x.as_mut())`.
|
|
|
|
|
|
|
|
Foo::baz(x);
|
|
|
|
Foo::baz(x);
|
2024-09-19 16:27:09 -07:00
|
|
|
|
|
|
|
foo_const(x); // make sure we can reborrow &mut as &.
|
|
|
|
|
|
|
|
let x: Pin<&Foo> = Pin::new(&Foo);
|
|
|
|
|
|
|
|
foo_const(x); // make sure reborrowing from & to & works.
|
2024-09-04 16:03:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|