diff options
| author | Eric Holk <ericholk@microsoft.com> | 2024-09-19 17:23:46 -0700 |
|---|---|---|
| committer | Eric Holk <ericholk@microsoft.com> | 2024-09-23 09:12:36 -0700 |
| commit | 97fbcf6773fa2d00675cbd7ea8dcdac1d6772072 (patch) | |
| tree | dd78c090c8e789eb8e7e7c49c9aee0da94bd2cda /tests | |
| parent | c22a4215a0f6fb676d3774d3763d9da1462414f5 (diff) | |
| download | rust-97fbcf6773fa2d00675cbd7ea8dcdac1d6772072.tar.gz rust-97fbcf6773fa2d00675cbd7ea8dcdac1d6772072.zip | |
Allow reborrowing Pin<&mut Self>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/async-await/pin-reborrow-self.rs | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/tests/ui/async-await/pin-reborrow-self.rs b/tests/ui/async-await/pin-reborrow-self.rs index b60b6982bb8..ab36ce575e1 100644 --- a/tests/ui/async-await/pin-reborrow-self.rs +++ b/tests/ui/async-await/pin-reborrow-self.rs @@ -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() {} |
