summaryrefslogtreecommitdiffstats
path: root/src/test/ui/self/arbitrary_self_types_pin_lifetime-async.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/self/arbitrary_self_types_pin_lifetime-async.rs')
-rw-r--r--src/test/ui/self/arbitrary_self_types_pin_lifetime-async.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime-async.rs b/src/test/ui/self/arbitrary_self_types_pin_lifetime-async.rs
new file mode 100644
index 000000000..f3474bc1f
--- /dev/null
+++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime-async.rs
@@ -0,0 +1,35 @@
+// check-pass
+// edition:2018
+
+use std::pin::Pin;
+use std::task::{Context, Poll};
+
+struct Foo;
+
+impl Foo {
+ async fn pin_ref(self: Pin<&Self>) -> Pin<&Self> { self }
+
+ async fn pin_mut(self: Pin<&mut Self>) -> Pin<&mut Self> { self }
+
+ async fn pin_pin_pin_ref(self: Pin<Pin<Pin<&Self>>>) -> Pin<Pin<Pin<&Self>>> { self }
+
+ async fn pin_ref_impl_trait(self: Pin<&Self>) -> impl Clone + '_ { self }
+
+ fn b(self: Pin<&Foo>, f: &Foo) -> Pin<&Foo> { self }
+}
+
+type Alias<T> = Pin<T>;
+impl Foo {
+ async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> Alias<&Self> { self }
+}
+
+// FIXME(Centril): extend with the rest of the non-`async fn` test
+// when we allow `async fn`s inside traits and trait implementations.
+
+fn main() {
+ let mut foo = Foo;
+ { Pin::new(&foo).pin_ref() };
+ { Pin::new(&mut foo).pin_mut() };
+ { Pin::new(Pin::new(Pin::new(&foo))).pin_pin_pin_ref() };
+ { Pin::new(&foo).pin_ref_impl_trait() };
+}