@@ -43,94 +43,144 @@ fn basic() {
4343 panic ! ( )
4444 }
4545
46- finish ( 1 , false , #[ coroutine] || yield 1 ) ;
46+ finish (
47+ 1 ,
48+ false ,
49+ #[ coroutine]
50+ || yield 1 ,
51+ ) ;
4752
48- finish ( 3 , false , #[ coroutine] || {
49- let mut x = 0 ;
50- yield 1 ;
51- x += 1 ;
52- yield 1 ;
53- x += 1 ;
54- yield 1 ;
55- assert_eq ! ( x, 2 ) ;
56- } ) ;
53+ finish (
54+ 3 ,
55+ false ,
56+ #[ coroutine]
57+ || {
58+ let mut x = 0 ;
59+ yield 1 ;
60+ x += 1 ;
61+ yield 1 ;
62+ x += 1 ;
63+ yield 1 ;
64+ assert_eq ! ( x, 2 ) ;
65+ } ,
66+ ) ;
5767
58- finish ( 7 * 8 / 2 , false , #[ coroutine] || {
59- for i in 0 ..8 {
60- yield i;
61- }
62- } ) ;
68+ finish (
69+ 7 * 8 / 2 ,
70+ false ,
71+ #[ coroutine]
72+ || {
73+ for i in 0 ..8 {
74+ yield i;
75+ }
76+ } ,
77+ ) ;
6378
64- finish ( 1 , false , #[ coroutine] || {
65- if true {
66- yield 1 ;
67- } else {
68- }
69- } ) ;
79+ finish (
80+ 1 ,
81+ false ,
82+ #[ coroutine]
83+ || {
84+ if true {
85+ yield 1 ;
86+ } else {
87+ }
88+ } ,
89+ ) ;
7090
71- finish ( 1 , false , #[ coroutine] || {
72- if false {
73- } else {
74- yield 1 ;
75- }
76- } ) ;
91+ finish (
92+ 1 ,
93+ false ,
94+ #[ coroutine]
95+ || {
96+ if false {
97+ } else {
98+ yield 1 ;
99+ }
100+ } ,
101+ ) ;
77102
78- finish ( 2 , false , #[ coroutine] || {
79- if {
80- yield 1 ;
81- false
82- } {
103+ finish (
104+ 2 ,
105+ false ,
106+ #[ coroutine]
107+ || {
108+ if {
109+ yield 1 ;
110+ false
111+ } {
112+ yield 1 ;
113+ panic ! ( )
114+ }
83115 yield 1 ;
84- panic ! ( )
85- }
86- yield 1 ;
87- } ) ;
116+ } ,
117+ ) ;
88118
89119 // also test self-referential coroutines
90120 assert_eq ! (
91- finish( 5 , true , #[ coroutine] static || {
92- let mut x = 5 ;
93- let y = & mut x;
94- * y = 5 ;
95- yield * y;
96- * y = 10 ;
97- x
98- } ) ,
121+ finish(
122+ 5 ,
123+ true ,
124+ #[ coroutine]
125+ static || {
126+ let mut x = 5 ;
127+ let y = & mut x;
128+ * y = 5 ;
129+ yield * y;
130+ * y = 10 ;
131+ x
132+ }
133+ ) ,
99134 10
100135 ) ;
101136 assert_eq ! (
102- finish( 5 , true , #[ coroutine] || {
103- let mut x = Box :: new( 5 ) ;
104- let y = & mut * x;
105- * y = 5 ;
106- yield * y;
107- * y = 10 ;
108- * x
109- } ) ,
137+ finish(
138+ 5 ,
139+ true ,
140+ #[ coroutine]
141+ || {
142+ let mut x = Box :: new( 5 ) ;
143+ let y = & mut * x;
144+ * y = 5 ;
145+ yield * y;
146+ * y = 10 ;
147+ * x
148+ }
149+ ) ,
110150 10
111151 ) ;
112152
113153 let b = true ;
114- finish ( 1 , false , #[ coroutine] || {
115- yield 1 ;
116- if b {
117- return ;
118- }
119- #[ allow( unused) ]
120- let x = never ( ) ;
121- #[ allow( unreachable_code) ]
122- yield 2 ;
123- drop ( x) ;
124- } ) ;
125-
126- finish ( 3 , false , #[ coroutine] || {
127- yield 1 ;
128- #[ allow( unreachable_code) ]
129- let _x: ( String , !) = ( String :: new ( ) , {
154+ finish (
155+ 1 ,
156+ false ,
157+ #[ coroutine]
158+ || {
159+ yield 1 ;
160+ if b {
161+ return ;
162+ }
163+ #[ allow( unused) ]
164+ let x = never ( ) ;
165+ #[ allow( unreachable_code) ]
130166 yield 2 ;
131- return ;
132- } ) ;
133- } ) ;
167+ drop ( x) ;
168+ } ,
169+ ) ;
170+
171+ finish (
172+ 3 ,
173+ false ,
174+ #[ coroutine]
175+ || {
176+ yield 1 ;
177+ #[ allow( unreachable_code) ]
178+ let _x: ( String , !) = ( String :: new ( ) , {
179+ yield 2 ;
180+ return ;
181+ } ) ;
182+ } ,
183+ ) ;
134184}
135185
136186fn smoke_resume_arg ( ) {
@@ -172,7 +222,8 @@ fn smoke_resume_arg() {
172222 }
173223
174224 drain (
175- & mut #[ coroutine] |mut b| {
225+ & mut #[ coroutine]
226+ |mut b| {
176227 while b != 0 {
177228 b = yield ( b + 1 ) ;
178229 }
@@ -181,21 +232,35 @@ fn smoke_resume_arg() {
181232 vec ! [ ( 1 , Yielded ( 2 ) ) , ( -45 , Yielded ( -44 ) ) , ( 500 , Yielded ( 501 ) ) , ( 0 , Complete ( -1 ) ) ] ,
182233 ) ;
183234
184- expect_drops ( 2 , || drain ( & mut #[ coroutine] |a| yield a, vec ! [ ( DropMe , Yielded ( DropMe ) ) ] ) ) ;
235+ expect_drops ( 2 , || {
236+ drain (
237+ & mut #[ coroutine]
238+ |a| yield a,
239+ vec ! [ ( DropMe , Yielded ( DropMe ) ) ] ,
240+ )
241+ } ) ;
185242
186243 expect_drops ( 6 , || {
187244 drain (
188- & mut #[ coroutine] |a| yield yield a,
245+ & mut #[ coroutine]
246+ |a| yield yield a,
189247 vec ! [ ( DropMe , Yielded ( DropMe ) ) , ( DropMe , Yielded ( DropMe ) ) , ( DropMe , Complete ( DropMe ) ) ] ,
190248 )
191249 } ) ;
192250
193251 #[ allow( unreachable_code) ]
194- expect_drops ( 2 , || drain ( & mut #[ coroutine] |a| yield return a, vec ! [ ( DropMe , Complete ( DropMe ) ) ] ) ) ;
252+ expect_drops ( 2 , || {
253+ drain (
254+ & mut #[ coroutine]
255+ |a| yield return a,
256+ vec ! [ ( DropMe , Complete ( DropMe ) ) ] ,
257+ )
258+ } ) ;
195259
196260 expect_drops ( 2 , || {
197261 drain (
198- & mut #[ coroutine] |a : DropMe | {
262+ & mut #[ coroutine]
263+ |a : DropMe | {
199264 if false { yield ( ) } else { a }
200265 } ,
201266 vec ! [ ( DropMe , Complete ( DropMe ) ) ] ,
@@ -205,7 +270,8 @@ fn smoke_resume_arg() {
205270 expect_drops ( 4 , || {
206271 drain (
207272 #[ allow( unused_assignments, unused_variables) ]
208- & mut #[ coroutine] |mut a : DropMe | {
273+ & mut #[ coroutine]
274+ |mut a : DropMe | {
209275 a = yield ;
210276 a = yield ;
211277 a = yield ;
@@ -228,7 +294,8 @@ fn uninit_fields() {
228294 }
229295
230296 fn run < T > ( x : bool , y : bool ) {
231- let mut c = #[ coroutine] || {
297+ let mut c = #[ coroutine]
298+ || {
232299 if x {
233300 let _a: T ;
234301 if y {
0 commit comments