]> git.lizzy.rs Git - rust.git/blob - src/test/ui/self/arbitrary_self_types_pin_lifetime-async.rs
Update ui tests
[rust.git] / src / test / ui / self / arbitrary_self_types_pin_lifetime-async.rs
1 // check-pass
2 // edition:2018
3
4 use std::pin::Pin;
5 use std::task::{Context, Poll};
6
7 struct Foo;
8
9 impl Foo {
10     async fn pin_ref(self: Pin<&Self>) -> Pin<&Self> { self }
11
12     async fn pin_mut(self: Pin<&mut Self>) -> Pin<&mut Self> { self }
13
14     async fn pin_pin_pin_ref(self: Pin<Pin<Pin<&Self>>>) -> Pin<Pin<Pin<&Self>>> { self }
15
16     async fn pin_ref_impl_trait(self: Pin<&Self>) -> impl Clone + '_ { self }
17
18     fn b(self: Pin<&Foo>, f: &Foo) -> Pin<&Foo> { self }
19 }
20
21 type Alias<T> = Pin<T>;
22 impl Foo {
23     async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> Alias<&Self> { self }
24 }
25
26 // FIXME(Centril): extend with the rest of the non-`async fn` test
27 // when we allow `async fn`s inside traits and trait implementations.
28
29 fn main() {
30     let mut foo = Foo;
31     { Pin::new(&foo).pin_ref() };
32     { Pin::new(&mut foo).pin_mut() };
33     { Pin::new(Pin::new(Pin::new(&foo))).pin_pin_pin_ref() };
34     { Pin::new(&foo).pin_ref_impl_trait() };
35 }