rust/tests/ui/async-await/pin-reborrow-self.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
556 B
Rust
Raw Normal View History

//@ check-pass
#![feature(pin_ergonomics)]
#![allow(incomplete_features)]
use std::pin::Pin;
2024-09-19 19:23:46 -05:00
pub struct Foo;
impl Foo {
fn foo(self: Pin<&mut Self>) {
}
2024-09-19 19:23:46 -05:00
fn baz(self: Pin<&Self>) {
}
}
2024-09-19 19:23:46 -05:00
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()`.
2024-09-19 19:23:46 -05:00
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() {}