about summary refs log tree commit diff
path: root/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.rs')
-rw-r--r--src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.rs b/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.rs
new file mode 100644
index 00000000000..27f789e340d
--- /dev/null
+++ b/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.rs
@@ -0,0 +1,27 @@
+// edition:2018
+
+// Test that a feature gate is needed to use `impl Trait` as the
+// return type of an async.
+
+#![feature(async_await, member_constraints)]
+
+trait Trait<'a> { }
+impl<T> Trait<'_> for T { }
+
+// Only `'a` permitted in return type, not `'b`.
+async fn async_ret_impl_trait1<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> {
+    //~^ ERROR lifetime mismatch
+    (a, b)
+}
+
+// As above, but `'b: 'a`, so return type ca be inferred to `(&'a u8,
+// &'a u8)`.
+async fn async_ret_impl_trait2<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a>
+where
+    'b: 'a,
+{
+    (a, b)
+}
+
+fn main() {
+}