about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorEric Holk <ericholk@microsoft.com>2023-12-04 13:43:38 -0800
committerEric Holk <ericholk@microsoft.com>2023-12-04 14:33:46 -0800
commit50ef8006eb68682471894c99b49eb4e39b48c745 (patch)
treee64b78caa9226fb5267e38afffebf0813f228a33 /tests
parent26f9954971a2895580e02578fe18bc6f9adea3c9 (diff)
downloadrust-50ef8006eb68682471894c99b49eb4e39b48c745.tar.gz
rust-50ef8006eb68682471894c99b49eb4e39b48c745.zip
Address code review feedback
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/coroutine/gen_fn_lifetime_capture.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/ui/coroutine/gen_fn_lifetime_capture.rs b/tests/ui/coroutine/gen_fn_lifetime_capture.rs
new file mode 100644
index 00000000000..b6a4d71e6cc
--- /dev/null
+++ b/tests/ui/coroutine/gen_fn_lifetime_capture.rs
@@ -0,0 +1,19 @@
+// edition: 2024
+// compile-flags: -Zunstable-options
+// check-pass
+#![feature(gen_blocks)]
+
+// make sure gen fn captures lifetimes in its signature
+
+gen fn foo<'a, 'b>(x: &'a i32, y: &'b i32, z: &'b i32) -> &'b i32 {
+    yield y;
+    yield z;
+}
+
+fn main() {
+    let z = 3;
+    let mut iter = foo(&1, &2, &z);
+    assert_eq!(iter.next(), Some(&2));
+    assert_eq!(iter.next(), Some(&3));
+    assert_eq!(iter.next(), None);
+}