]> git.lizzy.rs Git - rust.git/blob - tests/ui/generator/drop-track-addassign-yield.rs
Rollup merge of #106638 - RalfJung:realstd, r=thomcc
[rust.git] / tests / ui / generator / drop-track-addassign-yield.rs
1 // run-pass
2 // compile-flags: -Zdrop-tracking
3
4 // Based on addassign-yield.rs, but with drop tracking enabled. Originally we did not implement
5 // the fake_read callback on ExprUseVisitor which caused this case to break.
6
7 #![feature(generators)]
8
9 fn foo() {
10     let _y = static || {
11         let x = &mut 0;
12         *{
13             yield;
14             x
15         } += match String::new() {
16             _ => 0,
17         };
18     };
19
20     // Please don't ever actually write something like this
21     let _z = static || {
22         let x = &mut 0;
23         *{
24             let inner = &mut 1;
25             *{
26                 yield ();
27                 inner
28             } += match String::new() {
29                 _ => 1,
30             };
31             yield;
32             x
33         } += match String::new() {
34             _ => 2,
35         };
36     };
37 }
38
39 fn main() {
40     foo()
41 }