diff options
| author | Eric Holk <ericholk@microsoft.com> | 2023-12-04 13:43:38 -0800 |
|---|---|---|
| committer | Eric Holk <ericholk@microsoft.com> | 2023-12-04 14:33:46 -0800 |
| commit | 50ef8006eb68682471894c99b49eb4e39b48c745 (patch) | |
| tree | e64b78caa9226fb5267e38afffebf0813f228a33 /tests | |
| parent | 26f9954971a2895580e02578fe18bc6f9adea3c9 (diff) | |
| download | rust-50ef8006eb68682471894c99b49eb4e39b48c745.tar.gz rust-50ef8006eb68682471894c99b49eb4e39b48c745.zip | |
Address code review feedback
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/coroutine/gen_fn_lifetime_capture.rs | 19 |
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); +} |
