]> git.lizzy.rs Git - rust.git/blob - src/test/ui/generator/addassign-yield.rs
Auto merge of #102655 - joboet:windows_tls_opt, r=ChrisDenton
[rust.git] / src / test / ui / generator / addassign-yield.rs
1 // run-pass
2 // Regression test for broken MIR error (#61442)
3 // Due to the two possible evaluation orders for
4 // a '+=' expression (depending on whether or not the 'AddAssign' trait
5 // is being used), we were failing to account for all types that might
6 // possibly be live across a yield point.
7
8 #![feature(generators)]
9
10 fn foo() {
11     let _x = static || {
12         let mut s = String::new();
13         s += { yield; "" };
14     };
15
16     let _y = static || {
17         let x = &mut 0;
18         *{ yield; x } += match String::new() { _ => 0 };
19     };
20
21     // Please don't ever actually write something like this
22     let _z = static || {
23         let x = &mut 0;
24         *{
25             let inner = &mut 1;
26             *{ yield (); inner } += match String::new() { _ => 1};
27             yield;
28             x
29         } += match String::new() { _ => 2 };
30     };
31 }
32
33 fn main() {
34     foo()
35 }