summaryrefslogtreecommitdiffstats
path: root/src/test/ui/async-await/issue-61949-self-return-type.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/async-await/issue-61949-self-return-type.rs')
-rw-r--r--src/test/ui/async-await/issue-61949-self-return-type.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/test/ui/async-await/issue-61949-self-return-type.rs b/src/test/ui/async-await/issue-61949-self-return-type.rs
new file mode 100644
index 000000000..43429ba23
--- /dev/null
+++ b/src/test/ui/async-await/issue-61949-self-return-type.rs
@@ -0,0 +1,26 @@
+// edition:2018
+
+// This test checks that `Self` is prohibited as a return type. See #61949 for context.
+
+pub struct Foo<'a> {
+ pub bar: &'a i32,
+}
+
+impl<'a> Foo<'a> {
+ pub async fn new(_bar: &'a i32) -> Self {
+ //~^ ERROR `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope
+ Foo {
+ bar: &22
+ }
+ }
+}
+
+async fn foo() {
+ let x = {
+ let bar = 22;
+ Foo::new(&bar).await
+ };
+ drop(x);
+}
+
+fn main() { }