about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDing Xiang Fei <dingxiangfei2009@protonmail.ch>2020-08-06 16:18:46 +0800
committerDing Xiang Fei <dingxiangfei2009@protonmail.ch>2020-10-14 00:50:56 +0800
commit323f0794c09a545881180a391c9c68765216df5d (patch)
tree1c0e0ac396c2a7e284b4f7b37d353022c95f53bb
parent7f5721c3f470f9c393db239c01dc051ec84430c8 (diff)
downloadrust-323f0794c09a545881180a391c9c68765216df5d.tar.gz
rust-323f0794c09a545881180a391c9c68765216df5d.zip
test derived from #74961
-rw-r--r--src/test/ui/generator/yielding-in-match-guards.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/ui/generator/yielding-in-match-guards.rs b/src/test/ui/generator/yielding-in-match-guards.rs
new file mode 100644
index 00000000000..88c1424ce14
--- /dev/null
+++ b/src/test/ui/generator/yielding-in-match-guards.rs
@@ -0,0 +1,29 @@
+// check-pass
+// edition:2018
+
+// This test is derived from
+// https://github.com/rust-lang/rust/issues/74961#issuecomment-666893845
+// by @SNCPlay42
+
+// This test demonstrates that, in `async fn g()`,
+// indeed a temporary borrow `y` from `x` is live
+// while `f().await` is being evaluated.
+// Thus, `&'_ A` should be included in type signature
+// of the underlying generator.
+
+#[derive(PartialEq, Eq)]
+struct A;
+
+async fn f() -> A {
+    A
+}
+
+async fn g() {
+    let x = A;
+    match x {
+        y if f().await == y => {}
+        _ => {}
+    }
+}
+
+fn main() {}
\ No newline at end of file